0
Unit 1: Introduction to Software Testing Reading: JKR Ch. 4, W Ch. 1-2
What is software testing?
What is the goal of software testing?
Test Terminology <ul><li>test case : A set of inputs, execution conditions, and a pass/fail criterion. </li></ul><ul><ul><...
More Test Terminology <ul><li>defect : A mistake in the source code (static) </li></ul><ul><ul><li>Synonyms:  fault ,  bug...
From Defects to Failures <ul><li>Programmer creates a  defect </li></ul><ul><ul><li>Doesn’t necessarily mean the programme...
Software Testing is Hard. Why?
Challenge of Testing <ul><li>class Roots {   // Solve ax 2  + bx + c = 0   public roots(double a, double b,  </li></ul><ul...
Oracle Problem <ul><li>Given a particular input, how do we know the expected output is correct? </li></ul><ul><li>How to a...
Other Techniques of Finding Bugs?
Program Analysis <ul><li>Create software tools that detect defects by analyzing the source code automatically  </li></ul><...
Inspection <ul><li>Inspection : manual analyzing the software </li></ul><ul><li>Inspection can be applied to essentially a...
Verification and Validation (V&V) <ul><li>Validation :  does the software system meets the user's real needs? </li></ul><u...
Verification and Validation (V&V) Actual Requirements SW Specs System Validation Verification Includes usability testing, ...
Testing in the SW Development Process <ul><li>Verification is one of the main phases of the waterfall model: </li></ul><ul...
Testing in the SW Development Process <ul><li>Testing is executed late in the process since it requires code to run. </li>...
Early Testing Activities <ul><li>Early test generation </li></ul><ul><ul><li>Tests generated independently from code </li>...
Unit Testing <ul><li>Unit testing : Testing of a “unit” in the program. </li></ul><ul><ul><li>Unit: smallest part of the p...
Integration Testing <ul><li>Integration testing : Testing the interactions of the different units. </li></ul><ul><ul><li>A...
System Testing <ul><li>System testing : Testing the entire system. </li></ul><ul><ul><li>Requires the entire system to be ...
Regression Testing <ul><li>Regression Testing : A suite of tests used to make sure that the program has not regressed. </l...
Testing still needed late <ul><li>Could provide a mechanism for detecting bugs when the product has been released out in t...
How much testing is needed?
Product Quality Goals <ul><li>internal qualities: not directly visible to the end user </li></ul><ul><ul><li>maintainabili...
Dependability Qualities <ul><li>Correctness : A program is correct if it is consistent with its specification </li></ul><u...
Example:  Dependability Qualities   <ul><li>Correctness, reliability:  Let traffic pass according to correct pattern and c...
Tradeoffs <ul><li>From a managerial point-of-view,  there are tradeoffs: </li></ul><ul><ul><li>higher quality    more tim...
Test Adequacy <ul><li>Test adequacy measures how effective our test suite is. </li></ul><ul><ul><li>If the system passes a...
Adequacy Criteria as Design Rules <ul><li>Many design disciplines employ design rules: </li></ul><ul><ul><li>“ Traces (on ...
Practical (in)Adequacy Criteria <ul><li>Criteria that identify inadequacies in test suites:  </li></ul><ul><ul><li>If the ...
Adequacy Criteria <ul><li>Test obligation : A partial test case specification, requiring some property deemed important to...
Where do adequacy criteria come from? <ul><li>Functional (black box): from software specifications </li></ul><ul><ul><li>E...
Uses of Adequacy Criteria <ul><li>Test selection approaches </li></ul><ul><ul><li>Guidance in devising a thorough test sui...
Discussion: Prevention vs. Detection <ul><li>One way of reducing the number of bugs in a program is to prevent them from b...
Discussion: Manual vs. Automated <ul><li>Should tests be automated or carried out manually?  </li></ul>
Upcoming SlideShare
Loading in...5
×

Unit 1: Introduction to Software Testing

1,137

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,137
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
50
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Unit 1: Introduction to Software Testing"

  1. 1. Unit 1: Introduction to Software Testing Reading: JKR Ch. 4, W Ch. 1-2
  2. 2. What is software testing?
  3. 3. What is the goal of software testing?
  4. 4. Test Terminology <ul><li>test case : A set of inputs, execution conditions, and a pass/fail criterion. </li></ul><ul><ul><li>Example: height input is 5, width input is “Hello”, the test passes if the program produces an error message. </li></ul></ul><ul><li>test or test execution : The activity of executing test cases and evaluating their results. </li></ul><ul><li>test suite : A set of test cases. </li></ul>
  5. 5. More Test Terminology <ul><li>defect : A mistake in the source code (static) </li></ul><ul><ul><li>Synonyms: fault , bug </li></ul></ul><ul><li>infection : An incorrect program state – while the program is running (dynamic) </li></ul><ul><li>failure : An observable incorrect program behavior (output) </li></ul><ul><li>debugging : The process of finding and correcting a fault in a program given a failure </li></ul>
  6. 6. From Defects to Failures <ul><li>Programmer creates a defect </li></ul><ul><ul><li>Doesn’t necessarily mean the programmer is at fault </li></ul></ul><ul><li>The defect causes an infection </li></ul><ul><li>The infection propagates </li></ul><ul><li>The infection causes a failure </li></ul><ul><li>Goal of testing is to find failures </li></ul><ul><ul><li>With help of tools, could also find infections </li></ul></ul><ul><ul><li>Debugging is necessary to find the defect </li></ul></ul>
  7. 7. Software Testing is Hard. Why?
  8. 8. Challenge of Testing <ul><li>class Roots { // Solve ax 2 + bx + c = 0 public roots(double a, double b, </li></ul><ul><li>double c) { … } </li></ul><ul><li>// Result: values for x double root_one, root_two; </li></ul><ul><li>} </li></ul>
  9. 9. Oracle Problem <ul><li>Given a particular input, how do we know the expected output is correct? </li></ul><ul><li>How to address the oracle problem? </li></ul>
  10. 10. Other Techniques of Finding Bugs?
  11. 11. Program Analysis <ul><li>Create software tools that detect defects by analyzing the source code automatically </li></ul><ul><li>Most tools look for specific properties: </li></ul><ul><ul><li>Improper memory usage, race conditions, security violations </li></ul></ul><ul><li>Benefits: </li></ul><ul><ul><li>Can “symbolically” handle all inputs in a single analysis </li></ul></ul><ul><ul><li>Can potentially prove that a program is correct with respect to a property </li></ul></ul><ul><ul><li>Can be applied at any development stage </li></ul></ul><ul><li>Downsides: </li></ul><ul><ul><li>Proving a property is often computationally infeasible, inaccuracy is introduced to address this issue </li></ul></ul><ul><ul><li>Not all behaviors can be effectively captured using automated analysis </li></ul></ul>
  12. 12. Inspection <ul><li>Inspection : manual analyzing the software </li></ul><ul><li>Inspection can be applied to essentially any document: </li></ul><ul><ul><li>requirements </li></ul></ul><ul><ul><li>architectural and detailed design documents </li></ul></ul><ul><ul><li>test plans and test cases </li></ul></ul><ul><ul><li>program source code </li></ul></ul><ul><li>Secondary benefits: </li></ul><ul><ul><li>spreading good practices </li></ul></ul><ul><ul><li>instilling shared standards of quality </li></ul></ul><ul><li>Downsides: </li></ul><ul><ul><li>takes a considerable amount of time </li></ul></ul><ul><ul><li>reinspecting a changed component can be expensive </li></ul></ul>
  13. 13. Verification and Validation (V&V) <ul><li>Validation : does the software system meets the user's real needs? </li></ul><ul><li>are we building the right software? </li></ul><ul><li>Verification : does the software system meets the requirements specifications? </li></ul><ul><li>are we building the software right? </li></ul>
  14. 14. Verification and Validation (V&V) Actual Requirements SW Specs System Validation Verification Includes usability testing, user feedback Includes testing, inspections, static analysis
  15. 15. Testing in the SW Development Process <ul><li>Verification is one of the main phases of the waterfall model: </li></ul><ul><li>The earlier a defect is detected, the cheaper it is to fix. </li></ul><ul><li>Quality needs to be integrated into the entire process, not just added at the end. </li></ul>
  16. 16. Testing in the SW Development Process <ul><li>Testing is executed late in the process since it requires code to run. </li></ul><ul><li>However testing activities can begin much earlier in the development process. </li></ul><ul><li>Testing can be begin as soon as code is available: </li></ul><ul><ul><li>Unit testing </li></ul></ul><ul><ul><li>Integration testing </li></ul></ul><ul><ul><li>System testing </li></ul></ul><ul><ul><li>Regression testing </li></ul></ul><ul><li>Testing is not finished when the product is released. </li></ul>
  17. 17. Early Testing Activities <ul><li>Early test generation </li></ul><ul><ul><li>Tests generated independently from code </li></ul></ul><ul><ul><li>Generation of test cases may highlight inconsistencies and incompleteness of the corresponding specifications </li></ul></ul><ul><li>Planning the testing process </li></ul><ul><ul><li>How much testing is needed? </li></ul></ul><ul><ul><li>What order do we test the software? </li></ul></ul><ul><ul><li>Risk management </li></ul></ul><ul><li>Designing for test </li></ul><ul><ul><li>Scaffolding – permits “partial” code to be tested </li></ul></ul><ul><ul><li>Oracles – checks the results of tests </li></ul></ul>
  18. 18. Unit Testing <ul><li>Unit testing : Testing of a “unit” in the program. </li></ul><ul><ul><li>Unit: smallest part of the program – only assigned to one developer. </li></ul></ul><ul><ul><ul><li>Often a single function or class. </li></ul></ul></ul><ul><ul><li>Focuses on the functionality of that unit. </li></ul></ul><ul><ul><li>Often done by the developer </li></ul></ul><ul><ul><li>Automated using unit testing tools </li></ul></ul><ul><ul><ul><li>Visual Studio </li></ul></ul></ul><ul><ul><ul><li>JUnit </li></ul></ul></ul>
  19. 19. Integration Testing <ul><li>Integration testing : Testing the interactions of the different units. </li></ul><ul><ul><li>Assumes unit testing is complete or will catch errors within the unit. </li></ul></ul><ul><ul><li>Focuses on the interactions between units. </li></ul></ul><ul><ul><li>Depends on how the software constructed. </li></ul></ul><ul><ul><ul><li>Build-order: what units are built first. </li></ul></ul></ul><ul><ul><ul><li>Controllability: controlling the inputs necessary to carry out the test. </li></ul></ul></ul><ul><ul><ul><li>Observability: viewing the outputs necessary to determine if the test passed or now. </li></ul></ul></ul><ul><ul><li>Especially important in object-oriented development. </li></ul></ul><ul><ul><li>Often done by a testing team. </li></ul></ul><ul><ul><li>Can be tested manually or can be automated. </li></ul></ul>
  20. 20. System Testing <ul><li>System testing : Testing the entire system. </li></ul><ul><ul><li>Requires the entire system to be present. </li></ul></ul><ul><ul><li>Used to test common usage scenarios. </li></ul></ul><ul><ul><ul><li>Validation: Are we building the right software? </li></ul></ul></ul><ul><ul><ul><li>Verification: Are we building the software right? </li></ul></ul></ul><ul><ul><li>Used to test non-functional requirements. </li></ul></ul><ul><ul><ul><li>Performance </li></ul></ul></ul><ul><ul><ul><li>Compatibility </li></ul></ul></ul><ul><ul><ul><li>Usability </li></ul></ul></ul><ul><ul><ul><li>Security </li></ul></ul></ul><ul><ul><li>Best tested manually. </li></ul></ul><ul><ul><ul><li>Testing approaches are vastly different for non-functional requirements. </li></ul></ul></ul>
  21. 21. Regression Testing <ul><li>Regression Testing : A suite of tests used to make sure that the program has not regressed. </li></ul><ul><ul><li>Used to make sure that new features / modifications do not break existing working functionality. </li></ul></ul><ul><ul><li>Consists of tests that captures all of the functionality of the program. </li></ul></ul><ul><ul><ul><li>Especially important are tests that have found failures in the past! </li></ul></ul></ul><ul><ul><li>Tests are automated. </li></ul></ul><ul><ul><ul><li>Typically run before changes are committed. </li></ul></ul></ul>
  22. 22. Testing still needed late <ul><li>Could provide a mechanism for detecting bugs when the product has been released out in the field </li></ul><ul><li>Testing is needed for each… </li></ul><ul><ul><li>successive version of the software </li></ul></ul><ul><ul><li>time a bug has been fixed </li></ul></ul><ul><li>Post-mortem testing analysis </li></ul><ul><ul><li>Improving the testing process </li></ul></ul><ul><ul><li>Improving the design and development process </li></ul></ul>
  23. 23. How much testing is needed?
  24. 24. Product Quality Goals <ul><li>internal qualities: not directly visible to the end user </li></ul><ul><ul><li>maintainability </li></ul></ul><ul><ul><li>reusability </li></ul></ul><ul><li>external qualities: directly visible to the end user </li></ul><ul><ul><li>usefulness qualities: usability, performance, portability, interoperability </li></ul></ul><ul><ul><li>dependability qualities: correctness, reliability, safety, robustness </li></ul></ul>
  25. 25. Dependability Qualities <ul><li>Correctness : A program is correct if it is consistent with its specification </li></ul><ul><ul><li>seldom practical for non-trivial systems </li></ul></ul><ul><li>Reliability : Likelihood of correct function for some ”unit” of behavior </li></ul><ul><ul><li>relative to a specification and usage profile </li></ul></ul><ul><ul><li>statistical approximation to correctness (100% reliable = correct) </li></ul></ul><ul><li>Safety : Preventing hazards (certain undesirable behaviors) </li></ul><ul><li>Robustness : Acceptable (degraded) behavior under extreme conditions </li></ul>
  26. 26. Example: Dependability Qualities <ul><li>Correctness, reliability: Let traffic pass according to correct pattern and central scheduling </li></ul><ul><li>Safety: Never signal conflicting greens </li></ul><ul><li>Robustness: Provide degraded function if needed </li></ul><ul><ul><li>Blinking red / yellow is better than no lights </li></ul></ul><ul><ul><li>No lights is better than conflicting greens </li></ul></ul>
  27. 27. Tradeoffs <ul><li>From a managerial point-of-view, there are tradeoffs: </li></ul><ul><ul><li>higher quality  more time </li></ul></ul><ul><ul><li>higher quality  more costs </li></ul></ul><ul><li>For mass-market products, will typically sacrifice some level of quality to reduce time-to-market and costs. </li></ul><ul><li>Some software requires an extremely high level of quality </li></ul><ul><ul><li>medical devices </li></ul></ul><ul><ul><li>avionics </li></ul></ul>
  28. 28. Test Adequacy <ul><li>Test adequacy measures how effective our test suite is. </li></ul><ul><ul><li>If the system passes an adequate suite of test cases, then it must be correct. </li></ul></ul><ul><li>How do we measure the effectiveness of a test suite? </li></ul>
  29. 29. Adequacy Criteria as Design Rules <ul><li>Many design disciplines employ design rules: </li></ul><ul><ul><li>“ Traces (on a chip, on a circuit board) must be at least ___ wide and separated by at least ___” </li></ul></ul><ul><ul><li>“ The roof must have a pitch of at least ____ to shed snow” </li></ul></ul><ul><ul><li>“ Interstate highways must not have a grade greater than 6% without special review and approval” </li></ul></ul><ul><li>Design rules do not guarantee good designs </li></ul><ul><ul><li>Good design depends on talented, creative, disciplined designers. </li></ul></ul><ul><ul><li>Design rules help them avoid or spot flaws. </li></ul></ul><ul><ul><li>Test design is no different. </li></ul></ul>
  30. 30. Practical (in)Adequacy Criteria <ul><li>Criteria that identify inadequacies in test suites: </li></ul><ul><ul><li>If the specification describes different treatment in two cases, but the test suite does not check that the two cases are in fact treated differently, we may conclude that the test suite is inadequate to guard against faults in the program logic. </li></ul></ul><ul><ul><li>If no test in the test suite executes a particular program statement, the test suite is inadequate to guard against faults in that statement. </li></ul></ul><ul><li>If a test suite fails to satisfy some criterion, the obligation that has not been satisfied may provide some useful information about improving the test suite. </li></ul>
  31. 31. Adequacy Criteria <ul><li>Test obligation : A partial test case specification, requiring some property deemed important to thorough testing. </li></ul><ul><li>Adequacy criterion : A predicate that is true (satisfied) of a  program, test suite  pair. Requires both of these to be true: </li></ul><ul><ul><li>All tests must be passed </li></ul></ul><ul><ul><li>All test obligations must be satisfied by the test suite. </li></ul></ul><ul><li>If a test suite satisfies all of the adequacy criteria, is the test suite effective? </li></ul>
  32. 32. Where do adequacy criteria come from? <ul><li>Functional (black box): from software specifications </li></ul><ul><ul><li>Example: Make sure all the different situations detailed in the specification are tested. </li></ul></ul><ul><li>Structural (white or glass box): from code </li></ul><ul><ul><li>Example: Traverse each program loop one or more times. </li></ul></ul><ul><li>Model-based: from model of system </li></ul><ul><ul><li>Example: Exercise all transitions in communication protocol model </li></ul></ul>
  33. 33. Uses of Adequacy Criteria <ul><li>Test selection approaches </li></ul><ul><ul><li>Guidance in devising a thorough test suite </li></ul></ul><ul><ul><ul><li>Example: A functional-based criterion may suggest test cases covering representative combinations of values </li></ul></ul></ul><ul><ul><ul><li>Example: A structural-based criterion may require each statement to be executed once </li></ul></ul></ul><ul><li>Revealing missing tests </li></ul><ul><ul><li>Post hoc analysis: What might I have missed with this test suite? </li></ul></ul><ul><li>Often in combination </li></ul><ul><ul><li>First, design test suite from specifications using functional testing techniques. </li></ul></ul><ul><ul><li>Then, use structural criterion to highlight missed logic </li></ul></ul>
  34. 34. Discussion: Prevention vs. Detection <ul><li>One way of reducing the number of bugs in a program is to prevent them from being introduced in the first place. Should more effort go into prevention opposed to detection? </li></ul>
  35. 35. Discussion: Manual vs. Automated <ul><li>Should tests be automated or carried out manually? </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×