SlideShare a Scribd company logo
Software TestingSoftware Testing
TechniquesTechniques
Vibrant Technology & Computer 1
OutlineOutline
• What is Testing?What is Testing?
• Why Test?Why Test?
• How To Test The Tests?How To Test The Tests?
• Code Coverage (Peter)Code Coverage (Peter)
• How To Decide What To Test?How To Decide What To Test?
• Automation ToolsAutomation Tools
• Writing Test CasesWriting Test Cases
Vibrant Technology & Computer 2
What Is Testing?What Is Testing?
• In this context – confirming correctIn this context – confirming correct
behavior of a piece of software.behavior of a piece of software.
Vibrant Technology & Computer 3
Why Test?Why Test?
• We know what weWe know what we intendedintended thethe
code to do – we need to confirm thatcode to do – we need to confirm that
it does what we intended.it does what we intended.
Vibrant Technology & Computer 4
How To Test Our Tests?How To Test Our Tests?
• In other words: how can we be sureIn other words: how can we be sure
our tests are:our tests are:
– testing the right (relevant) “stuff”?testing the right (relevant) “stuff”?
– testing “most” of the code and not justtesting “most” of the code and not just
repeatedly testing the same code?repeatedly testing the same code?
Vibrant Technology & Computer 5
Code CoverageCode Coverage
• Take it away, Peter…Take it away, Peter…
Vibrant Technology & Computer 6
How To Decide What ToHow To Decide What To
Test?Test?
Low-Level
Classes
Application
Subsystems
YourProgram
Vibrant Technology & Computer 7
How To Decide (II)How To Decide (II)
• The trick is drawing a line acrossThe trick is drawing a line across
that triangle.that triangle.
– Draw it too low and you have too manyDraw it too low and you have too many
classes to test – and the tests aren’tclasses to test – and the tests aren’t
meaningful.meaningful.
– Draw it too high and a test failure leadsDraw it too high and a test failure leads
you on a wild goose chase…you on a wild goose chase…
• The bad news is – deciding where toThe bad news is – deciding where to
draw that line is an art, not adraw that line is an art, not a
science.science.
Vibrant Technology & Computer 8
Automation ToolsAutomation Tools
• How many times have you writtenHow many times have you written
code and then sat in front of thecode and then sat in front of the
keyboard running through testkeyboard running through test
cases?cases?
– How many times have you actuallyHow many times have you actually
thought about test cases?thought about test cases?
• The good news is that there is aThe good news is that there is a
better way.better way.
– And it’s never too late for a newAnd it’s never too late for a new
beginning…beginning…
Vibrant Technology & Computer 9
Automation To The RescueAutomation To The Rescue
• A few key tools:A few key tools:
– makemake
• make running tests a part of your buildmake running tests a part of your build
– scriptingscripting
• if you can automate it, automate itif you can automate it, automate it
– expectexpect
• a powerful toola powerful tool
Vibrant Technology & Computer 10
MakeMake
• Add a test rule to your makefileAdd a test rule to your makefile
– it should run all the tests– it should run all the tests
you’ve written and log theiryou’ve written and log their
results.results.
• If they all pass, you’re done – ifIf they all pass, you’re done – if
not, figure out why not.not, figure out why not.
Vibrant Technology & Computer 11
ScriptingScripting
• Imagine you have a bunch ofImagine you have a bunch of
executables that test various partsexecutables that test various parts
of your program.of your program.
– We’ll talk about how they might be builtWe’ll talk about how they might be built
shortly.shortly.
• Imagine you’ve written a shell scriptImagine you’ve written a shell script
to run them, one at a time.to run them, one at a time.
• How do you know when one fails?How do you know when one fails?
Vibrant Technology & Computer 12
Scripting (II)Scripting (II)
• You can check the exit code ofYou can check the exit code of
a program running from a shella program running from a shell
script:script:
– if [ $? –ne 0 ]; then … else … fiif [ $? –ne 0 ]; then … else … fi
• if the executable exitsif the executable exits
abnormally, the then clauseabnormally, the then clause
executes.executes.
Vibrant Technology & Computer 13
ExpectExpect
• Written by Don Libes – an extensionWritten by Don Libes – an extension
to Tclto Tcl
– What, you’ve never heard of tcl?What, you’ve never heard of tcl?
– That’s OK – there’s a python version asThat’s OK – there’s a python version as
well.well.
• If you’ve never heard of python, you shouldIf you’ve never heard of python, you should
have attended our python seminar…have attended our python seminar…
Vibrant Technology & Computer 14
Expect (II)Expect (II)
• It’s be installed on the lab machinesIt’s be installed on the lab machines
• Basic commands:Basic commands:
• spawnspawn
– run’s a new command under script control.run’s a new command under script control.
• sendsend
– provides input to the commandprovides input to the command
• expectexpect
– matches a pattern in the command outputmatches a pattern in the command output
Vibrant Technology & Computer 15
Expect (Example)Expect (Example)
#!/usr/bin/expect#!/usr/bin/expect
set timeout 5set timeout 5
spawn ssh –x [lindex $argv 0] “ls /”spawn ssh –x [lindex $argv 0] “ls /”
expect {expect {
timout {puts “timeout”}timout {puts “timeout”}
eof {exit 0}eof {exit 0}
““continue connecting (yes/no)? ” {send “yes” }continue connecting (yes/no)? ” {send “yes” }
}}
expect {expect {
eof {exit 0}eof {exit 0}
}}
Vibrant Technology & Computer 16
Python ExpectPython Expect
Pexpect –Pexpect – http://pexpect.sourceforge.nethttp://pexpect.sourceforge.net
Good News: Provides *most* of expect’sGood News: Provides *most* of expect’s
functionality from within python.functionality from within python.
Bad News: it’s not installed on the labBad News: it’s not installed on the lab
machines (yet?).machines (yet?).
Vibrant Technology & Computer 17
Writing Test CasesWriting Test Cases
• Write a simple executable that instantiatesWrite a simple executable that instantiates
a class, and “drives” that instance.a class, and “drives” that instance.
Vibrant Technology & Computer 18
Test Cases (Cont.)Test Cases (Cont.)
• Imagine you have a linked list class…Imagine you have a linked list class…
– If you wrote your own linked list class – andIf you wrote your own linked list class – and
you’re working in C++ - you should have been inyou’re working in C++ - you should have been in
our STL seminar.our STL seminar.
• What should your test program test?What should your test program test?
Vibrant Technology & Computer 19
Parting WordsParting Words
• Be a skeptic – you, as the developer, areBe a skeptic – you, as the developer, are
the only one who can crystal-box test yourthe only one who can crystal-box test your
code.code.
– Don’t test the easy cases – test the ones you’reDon’t test the easy cases – test the ones you’re
not sure about.not sure about.
– Don’t waste time testing the same thing moreDon’t waste time testing the same thing more
than once – break input into “equivalencethan once – break input into “equivalence
classes”classes”
Vibrant Technology & Computer 20
Thank You…Thank You…
Vibrant Technology & ComputerVibrant Technology & Computer
Vashi,Navi MumbaiVashi,Navi Mumbai
www.vibranttechnologies.comwww.vibranttechnologies.com
““100% job guarantee”100% job guarantee”
Vibrant Technology & Computer 21

More Related Content

PPT
Software testing (2) trainingin-mumbai...
PPT
Test Driven Development Part 1
PDF
Code-Review-Principles-Process-and-Tools (1)
PPTX
Are Automated Debugging Techniques Actually Helping Programmers
PDF
TDD and Getting Paid
PDF
Adversarial Simulation Nickerson/Gates Wild West Hacking Fest Oct 2017
PDF
Code review in practice
PDF
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...
Software testing (2) trainingin-mumbai...
Test Driven Development Part 1
Code-Review-Principles-Process-and-Tools (1)
Are Automated Debugging Techniques Actually Helping Programmers
TDD and Getting Paid
Adversarial Simulation Nickerson/Gates Wild West Hacking Fest Oct 2017
Code review in practice
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...

What's hot (11)

DOCX
Code review guidelines
PPTX
Clean code - Getting your R&D on board
PPT
Code Review
PDF
The View - 30 proven Lotuscript tips
PPTX
Working with Legacy Code
PDF
Effective code reviews
PDF
Going Purple : From full time breaker to part time fixer: 1 year later
PDF
Code Review: How and When
PDF
Unit testing legacy code
PDF
Test Drive Development
PDF
Code Review: How and When
Code review guidelines
Clean code - Getting your R&D on board
Code Review
The View - 30 proven Lotuscript tips
Working with Legacy Code
Effective code reviews
Going Purple : From full time breaker to part time fixer: 1 year later
Code Review: How and When
Unit testing legacy code
Test Drive Development
Code Review: How and When
Ad

Similar to Software testing (2) trainingin-mumbai (20)

PDF
1934015245
PDF
How to test a Mainframe Application
PDF
Software testing
PPT
Testing 1 - the Basics
PPTX
Software testing
PDF
Digital Transformation Requires Continuous Testing
PDF
Approaches to unraveling a complex test problem
PDF
ST-All about Test Case-p3
PDF
St all about test case-p3
PDF
SOFTWARE TESTING W1_watermark.pdf
PDF
Testing Slides 1 (Testing Intro+Static Testing).pdf
PDF
Presentation
PDF
Bdd and-testing
PDF
Behaviour Driven Development and Thinking About Testing
 
PDF
The Testing Planet - July 2010
PDF
Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010
PPT
Software Testing - Tool support for testing (CAST) - Mazenet Solution
PPTX
Sta unit 2(abimanyu)
PDF
Continuous Integration testing based on Selenium and Hudson
PDF
Open Source tools in Continuous Integration environment (case study for agil...
1934015245
How to test a Mainframe Application
Software testing
Testing 1 - the Basics
Software testing
Digital Transformation Requires Continuous Testing
Approaches to unraveling a complex test problem
ST-All about Test Case-p3
St all about test case-p3
SOFTWARE TESTING W1_watermark.pdf
Testing Slides 1 (Testing Intro+Static Testing).pdf
Presentation
Bdd and-testing
Behaviour Driven Development and Thinking About Testing
 
The Testing Planet - July 2010
Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010
Software Testing - Tool support for testing (CAST) - Mazenet Solution
Sta unit 2(abimanyu)
Continuous Integration testing based on Selenium and Hudson
Open Source tools in Continuous Integration environment (case study for agil...
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Modernizing your data center with Dell and AMD
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

Software testing (2) trainingin-mumbai

  • 2. OutlineOutline • What is Testing?What is Testing? • Why Test?Why Test? • How To Test The Tests?How To Test The Tests? • Code Coverage (Peter)Code Coverage (Peter) • How To Decide What To Test?How To Decide What To Test? • Automation ToolsAutomation Tools • Writing Test CasesWriting Test Cases Vibrant Technology & Computer 2
  • 3. What Is Testing?What Is Testing? • In this context – confirming correctIn this context – confirming correct behavior of a piece of software.behavior of a piece of software. Vibrant Technology & Computer 3
  • 4. Why Test?Why Test? • We know what weWe know what we intendedintended thethe code to do – we need to confirm thatcode to do – we need to confirm that it does what we intended.it does what we intended. Vibrant Technology & Computer 4
  • 5. How To Test Our Tests?How To Test Our Tests? • In other words: how can we be sureIn other words: how can we be sure our tests are:our tests are: – testing the right (relevant) “stuff”?testing the right (relevant) “stuff”? – testing “most” of the code and not justtesting “most” of the code and not just repeatedly testing the same code?repeatedly testing the same code? Vibrant Technology & Computer 5
  • 6. Code CoverageCode Coverage • Take it away, Peter…Take it away, Peter… Vibrant Technology & Computer 6
  • 7. How To Decide What ToHow To Decide What To Test?Test? Low-Level Classes Application Subsystems YourProgram Vibrant Technology & Computer 7
  • 8. How To Decide (II)How To Decide (II) • The trick is drawing a line acrossThe trick is drawing a line across that triangle.that triangle. – Draw it too low and you have too manyDraw it too low and you have too many classes to test – and the tests aren’tclasses to test – and the tests aren’t meaningful.meaningful. – Draw it too high and a test failure leadsDraw it too high and a test failure leads you on a wild goose chase…you on a wild goose chase… • The bad news is – deciding where toThe bad news is – deciding where to draw that line is an art, not adraw that line is an art, not a science.science. Vibrant Technology & Computer 8
  • 9. Automation ToolsAutomation Tools • How many times have you writtenHow many times have you written code and then sat in front of thecode and then sat in front of the keyboard running through testkeyboard running through test cases?cases? – How many times have you actuallyHow many times have you actually thought about test cases?thought about test cases? • The good news is that there is aThe good news is that there is a better way.better way. – And it’s never too late for a newAnd it’s never too late for a new beginning…beginning… Vibrant Technology & Computer 9
  • 10. Automation To The RescueAutomation To The Rescue • A few key tools:A few key tools: – makemake • make running tests a part of your buildmake running tests a part of your build – scriptingscripting • if you can automate it, automate itif you can automate it, automate it – expectexpect • a powerful toola powerful tool Vibrant Technology & Computer 10
  • 11. MakeMake • Add a test rule to your makefileAdd a test rule to your makefile – it should run all the tests– it should run all the tests you’ve written and log theiryou’ve written and log their results.results. • If they all pass, you’re done – ifIf they all pass, you’re done – if not, figure out why not.not, figure out why not. Vibrant Technology & Computer 11
  • 12. ScriptingScripting • Imagine you have a bunch ofImagine you have a bunch of executables that test various partsexecutables that test various parts of your program.of your program. – We’ll talk about how they might be builtWe’ll talk about how they might be built shortly.shortly. • Imagine you’ve written a shell scriptImagine you’ve written a shell script to run them, one at a time.to run them, one at a time. • How do you know when one fails?How do you know when one fails? Vibrant Technology & Computer 12
  • 13. Scripting (II)Scripting (II) • You can check the exit code ofYou can check the exit code of a program running from a shella program running from a shell script:script: – if [ $? –ne 0 ]; then … else … fiif [ $? –ne 0 ]; then … else … fi • if the executable exitsif the executable exits abnormally, the then clauseabnormally, the then clause executes.executes. Vibrant Technology & Computer 13
  • 14. ExpectExpect • Written by Don Libes – an extensionWritten by Don Libes – an extension to Tclto Tcl – What, you’ve never heard of tcl?What, you’ve never heard of tcl? – That’s OK – there’s a python version asThat’s OK – there’s a python version as well.well. • If you’ve never heard of python, you shouldIf you’ve never heard of python, you should have attended our python seminar…have attended our python seminar… Vibrant Technology & Computer 14
  • 15. Expect (II)Expect (II) • It’s be installed on the lab machinesIt’s be installed on the lab machines • Basic commands:Basic commands: • spawnspawn – run’s a new command under script control.run’s a new command under script control. • sendsend – provides input to the commandprovides input to the command • expectexpect – matches a pattern in the command outputmatches a pattern in the command output Vibrant Technology & Computer 15
  • 16. Expect (Example)Expect (Example) #!/usr/bin/expect#!/usr/bin/expect set timeout 5set timeout 5 spawn ssh –x [lindex $argv 0] “ls /”spawn ssh –x [lindex $argv 0] “ls /” expect {expect { timout {puts “timeout”}timout {puts “timeout”} eof {exit 0}eof {exit 0} ““continue connecting (yes/no)? ” {send “yes” }continue connecting (yes/no)? ” {send “yes” } }} expect {expect { eof {exit 0}eof {exit 0} }} Vibrant Technology & Computer 16
  • 17. Python ExpectPython Expect Pexpect –Pexpect – http://pexpect.sourceforge.nethttp://pexpect.sourceforge.net Good News: Provides *most* of expect’sGood News: Provides *most* of expect’s functionality from within python.functionality from within python. Bad News: it’s not installed on the labBad News: it’s not installed on the lab machines (yet?).machines (yet?). Vibrant Technology & Computer 17
  • 18. Writing Test CasesWriting Test Cases • Write a simple executable that instantiatesWrite a simple executable that instantiates a class, and “drives” that instance.a class, and “drives” that instance. Vibrant Technology & Computer 18
  • 19. Test Cases (Cont.)Test Cases (Cont.) • Imagine you have a linked list class…Imagine you have a linked list class… – If you wrote your own linked list class – andIf you wrote your own linked list class – and you’re working in C++ - you should have been inyou’re working in C++ - you should have been in our STL seminar.our STL seminar. • What should your test program test?What should your test program test? Vibrant Technology & Computer 19
  • 20. Parting WordsParting Words • Be a skeptic – you, as the developer, areBe a skeptic – you, as the developer, are the only one who can crystal-box test yourthe only one who can crystal-box test your code.code. – Don’t test the easy cases – test the ones you’reDon’t test the easy cases – test the ones you’re not sure about.not sure about. – Don’t waste time testing the same thing moreDon’t waste time testing the same thing more than once – break input into “equivalencethan once – break input into “equivalence classes”classes” Vibrant Technology & Computer 20
  • 21. Thank You…Thank You… Vibrant Technology & ComputerVibrant Technology & Computer Vashi,Navi MumbaiVashi,Navi Mumbai www.vibranttechnologies.comwww.vibranttechnologies.com ““100% job guarantee”100% job guarantee” Vibrant Technology & Computer 21