SlideShare a Scribd company logo
A beginners guide to testing Philip Johnson Collaborative Software Development Laboratory  Information and Computer Sciences University of Hawaii Honolulu HI 96822
Objectives Understand the basic concepts, terminology, and approaches to software testing. Be able to apply this information to improve the quality of your own testing efforts during software development.
Why is testing important?
First National Bank (1996) Problem: An error at First National Bank of Chicago resulted in the balance of 800 customers being inflated by a total of $763 billion. Reason: Inadequate testing. Bank updated ATM transaction software with new message codes. Message codes were not tested on all ATM protocols, resulting in some ATMs interpreting them as huge increases to customer balances.
Therac-25 (1985-1987) Problem: Six people were overexposed during radiation treatments for cancer by the Therac-25 radiation therapy machine. Three people were believed to have died from the overdoses. Reason: Inadequate testing. Hardware safety locks removed and replaced by software safety locks, which could be overcome by technician  “type ahead”.
Ariane 5 (1996) Problem: Ariane 5 rocket exploded on its maiden flight. Reason: Inadequate testing.  Navigation package inherited from Ariane-4 without proper testing.  New rocket flew faster, resulting in larger values of some variables, resulting in an attempt to convert a 64-bit floating number into a 16 bit integer. Code was caught and action taken was to shut down navigation system.
ICS 314, Fall 2011 Problem: A student got a bad grade for ICS 314. Reason: Inadequate testing. The student did not learn how to write good test cases for their code.
Testing fits into Validation and Verification Validation: Establishing the fitness of a software product for its use. “ Are we building the right product?” Requires interaction with customers. Verification: Establishing the correspondence between the software and its specification. “ Are we building the product right?” Requires interaction with software.
Static vs. Dynamic V&V Static V&V: Software inspections Static analysis of source code Control/data flow analysis Dynamic V&V: Defect testing Looks for errors in functionality Load testing Looks for errors in scalability, performance, reliability
Issues Is it  “testing” if you simply run the program to see what it does? Is validation testing done best with static or dynamic testing? Is verification testing done best with static or dynamic testing?
Why is testing hard? Exhaustive testing: Execute program on all possible inputs and compare actual to expected behavior. Could  “prove” program correctness. Not practical for any non-trivial program. Practical testing: Select a tiny % of all possible tests. Goal: executing the tiny % of tests will uncover a large % of defects present! A  “testing method” is essentially a way to decide which tiny % to pick.
How do we determine which tests to write? Selected examples: Functional (black box) testing Use specification to determine the tests Structural (white box) testing Use coverage to assess the quality of tests Test-driven development Write tests as specification Use tests to determine the implementation! Combinations of methods are acceptable!
Black box testing
Specification based testing Specification: A mapping between the possible  “inputs” to the program and the corresponding expected “outputs” Specification-based testing: Design a set of test cases to see if inputs actually map to outputs. Does not require access to source code Differences with White Box (coverage) testing: Can catch errors of omission. Effectiveness depends upon the quality of specification
Equivalence classes Goal: Divide the possible inputs into categories such that testing one point in each category is equivalent to testing all points in the category. Provide one test case for each point. Equivalence class definition is usually an iterative process and goes on throughout development. Use heuristics to get you started designing your test cases.
Unit test design heuristics If input is a value: maximum value minimum value empty value typical value illegal value If input is a sequence: Single element Empty sequence Max and min element values Sequences of different sizes Illegal elements If I/O specification contains conditions: true  false If I/O specification contains iterations: zero times 1 time > 1 time
Web app design heuristics Every page is retrieved at least once Prevent 404 errors. Every link is followed at least once. Prevent 404 errors. All form input fields are tested with: Normal values Erroneous values Maximum/minimum values Always check response for appropriateness.
Tool support: JUnit
Tool Support: JUnitReport
White box testing
Statement coverage For a test case to uncover a defect, the statement containing the defect must be executed. Therefore, a set of test cases which guarantees all statements are executed  might  uncover a large number of the defects present. Whether or not the defects are actually uncovered depends upon the program state at the time each statement is executed.
Control flow coverages Control flow coverage adds conditions to statement coverage to raise the odds of discovering defects. Branch coverage: Every conditional is evaluated as both true and false during testing. Loop coverage: Every loop must be executed both 0 times and more than 1 time. Path coverage: All permutations of paths through the program are taken
JaCoCo: A Java Coverage Tool
JaCoCo: Drilldown to Package
JaCoCo: Drilldown to Class
JaCoCo: Red regions not tested
“ Coverage-driven test case design” 1. Write some test cases to exercise your code in new ways. 2. Run your coverage tool. 3. If coverage is not 100%, go to 1.
“ Coverage-driven test case design”  is bad! Using coverage data to drive the design of your tests often results in a poorly designed test case suite. (See readings.) Instead, use coverage to  assess  the quality of your test method. In a nutshell: Good test design method -> Good coverage But not the other way around.
Limitations of white-box testing Can catch bugs in code that has been written. Cannot catch bugs in code that has not been written! Errors of omission: code that ought to have been written but wasn ’t Missing boolean conditions in IF statements Missing exception handlers To catch bugs in code that has not been written, you must compare behavior of program to its specification.
Quality assurance in this class You will use a combination of manual and automated quality assurance. Automated QA:  Use Checkstyle, PMD, FindBugs, and eliminate all warnings. Manual QA:  Use JUnit to develop tests, use Jacoco to check coverage.  Use Code Review to look for remaining errors.
 

More Related Content

PDF
Software Testing without Requirements: Survival Guide
PPT
Test case development
PDF
Mutation Testing
PDF
Combinatorial testing
PPTX
Combinatorial testing ppt
PPS
Lesson 2....PPT 1
PDF
Testing a GPS application | Testbytes
PDF
Exploring Exploratory Testing
Software Testing without Requirements: Survival Guide
Test case development
Mutation Testing
Combinatorial testing
Combinatorial testing ppt
Lesson 2....PPT 1
Testing a GPS application | Testbytes
Exploring Exploratory Testing

What's hot (20)

PPTX
Qa mockup interview for automation testing
PPT
Black box testing lecture 11
PDF
Automation testing interview pdf org
PPT
Testing 2 - Thinking Like A Tester
PDF
Test Smarter: Efficient Coverage Metrics That Won't Leave You Exposed
PPT
PPT
Testing Fundamentals
PDF
Best Practices In Exploratory Testing
DOC
Black box testing
PPT
Software Testing Tecniques
PPT
Testing
DOC
Lesson 4...Bug Life Cycle
DOCX
PPTX
Software Testing Foundations Part 4 - Black Box Testing
PDF
Black-Box
PPT
PDF
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
PPTX
Test design techniques
PDF
Unit testing - An introduction
PPT
Software Testing
Qa mockup interview for automation testing
Black box testing lecture 11
Automation testing interview pdf org
Testing 2 - Thinking Like A Tester
Test Smarter: Efficient Coverage Metrics That Won't Leave You Exposed
Testing Fundamentals
Best Practices In Exploratory Testing
Black box testing
Software Testing Tecniques
Testing
Lesson 4...Bug Life Cycle
Software Testing Foundations Part 4 - Black Box Testing
Black-Box
Tech talks annual 2015 izzet mustafayev_performance testing - the way to make...
Test design techniques
Unit testing - An introduction
Software Testing
Ad

Similar to A beginners guide to testing (20)

PPT
Testing Software Solutions
PPT
Software testing mtech project in jalandhar
PPT
Software testing mtech project in ludhiana
PPTX
Module 3-software testing.pptxwjduejsuehsueusueudsjejejejeuwuwuwu
PPTX
White-box testing.pptx
PPTX
software testing types jxnvlbnLCBNFVjnl/fknblb
PPT
Types of Software Testing
PPT
Testing
PDF
Test Case Design Techniques in Software Testing_ Elements, Types, and Best Pr...
DOCX
Chapter 10 Testing and Quality Assurance1Unders.docx
PDF
Testing Slides 1 (Testing Intro+Static Testing).pdf
PPS
Why Unit Testingl
PPS
Why Unit Testingl
PPS
Why unit testingl
PPT
Orthogonal array approach a case study
PPTX
Blackbox
PDF
Testing Interview Questions.pdf
PPTX
Importance of Software testing in SDLC and Agile
PPT
testing
PPT
Industrial Training in Software Testing
Testing Software Solutions
Software testing mtech project in jalandhar
Software testing mtech project in ludhiana
Module 3-software testing.pptxwjduejsuehsueusueudsjejejejeuwuwuwu
White-box testing.pptx
software testing types jxnvlbnLCBNFVjnl/fknblb
Types of Software Testing
Testing
Test Case Design Techniques in Software Testing_ Elements, Types, and Best Pr...
Chapter 10 Testing and Quality Assurance1Unders.docx
Testing Slides 1 (Testing Intro+Static Testing).pdf
Why Unit Testingl
Why Unit Testingl
Why unit testingl
Orthogonal array approach a case study
Blackbox
Testing Interview Questions.pdf
Importance of Software testing in SDLC and Agile
testing
Industrial Training in Software Testing
Ad

More from Philip Johnson (20)

PPTX
Kukui Cup 2012 Energy Data
PPTX
Introduction to ICS 691: Software Engineering for the Smart Grid
PPTX
Kukui Cup 2012 Organizing Committee February Meeting
PPTX
How to plan a Kukui Cup
PPT
Honors thesis overview: Katie Amberg-Johnson
PPT
Introduction to Issue Driven Project Management
PPT
Introduction to continuous integration
PPT
Introduction to WattDepot
PPT
Introduction to Subversion and Google Project Hosting
PPT
Introduction to Version Control and Configuration Management
PPT
Introduction to automated quality assurance
PPT
Introduction to Software Build Technology
PPT
Introduction to Software Review
PPT
Introduction to Robocode
PPT
Codings Standards
PPT
Interactive Development Environments
PPT
Introduction to Intermediate Java
PPT
Professional Persona
PPT
01.intro
PPTX
iHale Milestone 2 Kickoff
Kukui Cup 2012 Energy Data
Introduction to ICS 691: Software Engineering for the Smart Grid
Kukui Cup 2012 Organizing Committee February Meeting
How to plan a Kukui Cup
Honors thesis overview: Katie Amberg-Johnson
Introduction to Issue Driven Project Management
Introduction to continuous integration
Introduction to WattDepot
Introduction to Subversion and Google Project Hosting
Introduction to Version Control and Configuration Management
Introduction to automated quality assurance
Introduction to Software Build Technology
Introduction to Software Review
Introduction to Robocode
Codings Standards
Interactive Development Environments
Introduction to Intermediate Java
Professional Persona
01.intro
iHale Milestone 2 Kickoff

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
Programs and apps: productivity, graphics, security and other tools
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
sap open course for s4hana steps from ECC to s4
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf

A beginners guide to testing

  • 1. A beginners guide to testing Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu HI 96822
  • 2. Objectives Understand the basic concepts, terminology, and approaches to software testing. Be able to apply this information to improve the quality of your own testing efforts during software development.
  • 3. Why is testing important?
  • 4. First National Bank (1996) Problem: An error at First National Bank of Chicago resulted in the balance of 800 customers being inflated by a total of $763 billion. Reason: Inadequate testing. Bank updated ATM transaction software with new message codes. Message codes were not tested on all ATM protocols, resulting in some ATMs interpreting them as huge increases to customer balances.
  • 5. Therac-25 (1985-1987) Problem: Six people were overexposed during radiation treatments for cancer by the Therac-25 radiation therapy machine. Three people were believed to have died from the overdoses. Reason: Inadequate testing. Hardware safety locks removed and replaced by software safety locks, which could be overcome by technician “type ahead”.
  • 6. Ariane 5 (1996) Problem: Ariane 5 rocket exploded on its maiden flight. Reason: Inadequate testing. Navigation package inherited from Ariane-4 without proper testing. New rocket flew faster, resulting in larger values of some variables, resulting in an attempt to convert a 64-bit floating number into a 16 bit integer. Code was caught and action taken was to shut down navigation system.
  • 7. ICS 314, Fall 2011 Problem: A student got a bad grade for ICS 314. Reason: Inadequate testing. The student did not learn how to write good test cases for their code.
  • 8. Testing fits into Validation and Verification Validation: Establishing the fitness of a software product for its use. “ Are we building the right product?” Requires interaction with customers. Verification: Establishing the correspondence between the software and its specification. “ Are we building the product right?” Requires interaction with software.
  • 9. Static vs. Dynamic V&V Static V&V: Software inspections Static analysis of source code Control/data flow analysis Dynamic V&V: Defect testing Looks for errors in functionality Load testing Looks for errors in scalability, performance, reliability
  • 10. Issues Is it “testing” if you simply run the program to see what it does? Is validation testing done best with static or dynamic testing? Is verification testing done best with static or dynamic testing?
  • 11. Why is testing hard? Exhaustive testing: Execute program on all possible inputs and compare actual to expected behavior. Could “prove” program correctness. Not practical for any non-trivial program. Practical testing: Select a tiny % of all possible tests. Goal: executing the tiny % of tests will uncover a large % of defects present! A “testing method” is essentially a way to decide which tiny % to pick.
  • 12. How do we determine which tests to write? Selected examples: Functional (black box) testing Use specification to determine the tests Structural (white box) testing Use coverage to assess the quality of tests Test-driven development Write tests as specification Use tests to determine the implementation! Combinations of methods are acceptable!
  • 14. Specification based testing Specification: A mapping between the possible “inputs” to the program and the corresponding expected “outputs” Specification-based testing: Design a set of test cases to see if inputs actually map to outputs. Does not require access to source code Differences with White Box (coverage) testing: Can catch errors of omission. Effectiveness depends upon the quality of specification
  • 15. Equivalence classes Goal: Divide the possible inputs into categories such that testing one point in each category is equivalent to testing all points in the category. Provide one test case for each point. Equivalence class definition is usually an iterative process and goes on throughout development. Use heuristics to get you started designing your test cases.
  • 16. Unit test design heuristics If input is a value: maximum value minimum value empty value typical value illegal value If input is a sequence: Single element Empty sequence Max and min element values Sequences of different sizes Illegal elements If I/O specification contains conditions: true false If I/O specification contains iterations: zero times 1 time > 1 time
  • 17. Web app design heuristics Every page is retrieved at least once Prevent 404 errors. Every link is followed at least once. Prevent 404 errors. All form input fields are tested with: Normal values Erroneous values Maximum/minimum values Always check response for appropriateness.
  • 21. Statement coverage For a test case to uncover a defect, the statement containing the defect must be executed. Therefore, a set of test cases which guarantees all statements are executed might uncover a large number of the defects present. Whether or not the defects are actually uncovered depends upon the program state at the time each statement is executed.
  • 22. Control flow coverages Control flow coverage adds conditions to statement coverage to raise the odds of discovering defects. Branch coverage: Every conditional is evaluated as both true and false during testing. Loop coverage: Every loop must be executed both 0 times and more than 1 time. Path coverage: All permutations of paths through the program are taken
  • 23. JaCoCo: A Java Coverage Tool
  • 26. JaCoCo: Red regions not tested
  • 27. “ Coverage-driven test case design” 1. Write some test cases to exercise your code in new ways. 2. Run your coverage tool. 3. If coverage is not 100%, go to 1.
  • 28. “ Coverage-driven test case design” is bad! Using coverage data to drive the design of your tests often results in a poorly designed test case suite. (See readings.) Instead, use coverage to assess the quality of your test method. In a nutshell: Good test design method -> Good coverage But not the other way around.
  • 29. Limitations of white-box testing Can catch bugs in code that has been written. Cannot catch bugs in code that has not been written! Errors of omission: code that ought to have been written but wasn ’t Missing boolean conditions in IF statements Missing exception handlers To catch bugs in code that has not been written, you must compare behavior of program to its specification.
  • 30. Quality assurance in this class You will use a combination of manual and automated quality assurance. Automated QA: Use Checkstyle, PMD, FindBugs, and eliminate all warnings. Manual QA: Use JUnit to develop tests, use Jacoco to check coverage. Use Code Review to look for remaining errors.
  • 31.