1 / 104

CS 406 Fall 98 Software Testing Part III: Test Assessment and Improvement

CS 406 Fall 98 Software Testing Part III: Test Assessment and Improvement. Aditya P. Mathur Purdue university. Last update: July 19, 1998. Learning Objectives. To understand the relevance and importance of test assessment. To learn the fundamental principle underlying test assessment.

baruch
Download Presentation

CS 406 Fall 98 Software Testing Part III: Test Assessment and Improvement

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 406 Fall 98 Software TestingPart III:Test Assessment and Improvement Aditya P. Mathur Purdue university Last update: July 19, 1998

  2. Learning Objectives • To understand the relevance and importance of test assessment. • To learn the fundamental principle underlying test assessment. • To learn various methods and tools for test assessment. Test assessment and improvement

  3. Learning objectives • To understand the relative strengths/weaknesses of test assessment methods. • To learn how to improve tests based on a test assessment procedure. Test assessment and improvement

  4. What is test assessment? • Once a test set T, a collection of test inputs, has been developed, we ask: How good is T? • It is the measurement of the goodness of T which is known as test assessment. • Test assessment is carried out based on one or more criteria. Test assessment and improvement

  5. Test assessment-continued • These criteria are known as test adequacy criteria. • Test assessment is also known as test adequacy assessment. Test assessment and improvement

  6. Test assessment-continued • Test assessment provides the following information: • A metric, also known as the adequacy score or coverage, usually between 0 and 1. • A list of all the weaknesses found in T, which when removed, will raise the score to 1. • The weaknesses depend on the criteria used for assessment. Test assessment and improvement

  7. Test assessment-continued • Once the coverage has been computed, and the weaknesses identified, one can improve T. • Improvement of T is done by examining one or more weaknesses and constructing new test requirements designed to overcome the weakness(es). • The new test requirements lead to new test specifications and to further testing of the program. Test assessment and improvement

  8. Test assessment-continued • This is continued until all weaknesses are overcome, i.e. the adequacy criterion is satisfied (coverage=1). • In some instances it may not be possible to satisfy the adequacy criteria for one or more of the following reasons: • Lack of sufficient manpower • Weaknesses that cannot be removed because they are infeasible. Test assessment and improvement

  9. Test assessment-continued • The cost of removing the weaknesses is not justified. • While improving T by removing its weaknesses, one usually tests the program more thoroughly than it has been tested so far. • This additional testing is likely to result in the discovery of remaining errors. Test assessment and improvement

  10. Test assessment-continued • Hence we say that test assessment and improvement helps in the improvement of software reliability. • Test assessment and improvement is applicable throughout the testing process and during all stages of software development. Test assessment and improvement

  11. Test assessment-summary procedure 0 Develop T Select an adequacy criterion C. 1 2 Measure adequacy of T w.r.t. C. Yes 3 Is T adequate? Yes No 4 Improve T More testing is warranted ? 5 No 6 Done Test assessment and improvement

  12. Principle underlying test assessment • There is a uniform principle that underlies test assessment throughout the testing process. • This principle is known as the coverage principle. • It has come about as a result of intensive research at Purdue and other research groups in software testing. Test assessment and improvement

  13. The coverage principle • To formulate and understand the coverage principle, we need to understand: • coverage domains • coverage elements • A coverage domain is a finite domain, related to the program under test, that we want to cover. Coverage elements are the individual elements of this domain Test assessment and improvement

  14. The coverage principle-continued Coverage Domains Coverage Elements Requirements Classes Functions Interface mutations Exceptions Test assessment and improvement

  15. The coverage principle-continued • Measuring test adequacy and improving a test set against a sequence of well defined, increasingly strong, coverage domains leads to improved confidence in the reliability of the system under test. Test assessment and improvement

  16. The coverage principle-continued • Note the following properties of a coverage domain: • It is related to the program under test. • It is finite. • It may come from program requirements, related to the inputs and outputs. Test assessment and improvement

  17. The coverage principle-continued • It may come from program code. Can you think of a coverage domain that comes from the program code? • It aids in measuring test adequacy as well as the progress made in testing. How? Test assessment and improvement

  18. The coverage principle-continued • Example: • It is required to write a program that takes in the name of a person as a string and searches for the name in a file of names. The program must output the record ID which matches the given name. In case of no match a -1 is returned. What coverage domains can be identified from this requirement? Test assessment and improvement

  19. The coverage principle-continued • As we learned earlier, improving coverage improves our confidence in the correct functioning of the program under test. • Given a program P and a test T suppose that T is adequate w.r.t. a coverage criterion C. • Does this mean that P is error free? • Obviously……??? Test assessment and improvement

  20. Test effort • There are several measures of test effort. • One measure is the size of T. By this measure a test set with a larger number of test cases corresponds to higher effort than one with a lesser number of test cases. Test assessment and improvement

  21. Error detection effectiveness • Each coverage criterion has its error detection ability. This is also known as the error detection effectiveness or simply effectiveness of the criterion. • One measure of the effectiveness of criterion C is the fraction of faults guaranteed to be revealed by a test T that satisfies C. Test assessment and improvement

  22. Effectiveness-continued • Another measure is the probability that at least fraction f of the faults in P will be revealed by test T that satisfies C. • Unfortunately there is no absolute measure of the effectiveness of any given coverage criterion for a general class of programs and for arbitrary test sets. Test assessment and improvement

  23. Effectiveness-continued • One coverage criterion results in an exception to this rule: What is it? • Empirical studies conducted by researchers give us an idea of the relative goodness of various coverage criteria. • Thus, for a variety of criteria we can make a statement like: Criterion C1 is definitely better than criterion C2. Test assessment and improvement

  24. Effectiveness-continued • In some cases we may be able to say: Criterion C1 is probably better than criterion C2. • Such information allows us to construct a hierarchy of coverage criteria. • This hierarchy is helpful in organizing and managing testing. How? Test assessment and improvement

  25. Strength of a coverage criterion • The effectiveness of a coverage criterion is also referred to as its strength. • Strength is a measure of the criterion’s ability to reveal faults in a program. • Criterion C1 is considered stronger than criterion C2 if C1 is is capable of revealing more faults than C2. Test assessment and improvement

  26. The Saturation Effect • The rate at which new faults are discovered reduces as test adequacy with respect to a finite coverage domain increases; it reduces to zero when the coverage domain has been exhausted. 0 coverage 1 Test assessment and improvement

  27. Saturation Effect: Fault View N Remaining Faults M 0 tfs tfe tds tdfe tme Functional Testing Effort Test assessment and improvement

  28. True reliability (R) Estimated reliability (R’) Saturation region Saturation Effect: Reliability View R’m R’d R’df R’f Reliability Rm Rdf Mutation Rd Dataflow Rf Decision Functional tfs tfe tds tde tdfs tdfe tms tfe Testing Effort FUNCTIONAL, DECISION, DATAFLOW AND MUTATION COVERAGE PROVIDE VARIOUS TEST EVALUATION CRITERIA. Test assessment and improvement

  29. Coverage principle-discussion • Discuss: How will you use the knowledge of coverage principle and the saturation effect in organizing and managing testing? Can you think of any other uses of the coverage principle and the saturation effect? Test assessment and improvement

  30. Control flow graph • Control flow graph (CFG) of a program is a representation of the flow of execution within the program. • It is useful in program analysis such as that required during test assessment and improvement. • More formally, a CFG G is: Test assessment and improvement

  31. Control flow graph • G=(N,A) where N: set of nodes and A: set of arcs • There is a unique entry node en in N. • There is a unique exit node ex in N. A node represents a single statement or a block. • A block is a single-entry-single-exit sequence of instructions that are always executed in a sequence without any diversion of path except at the end of the block. Test assessment and improvement

  32. Control flow graph-continued • Every statement in a block, except possibly the first one, has exactly one predecessor. • Similarly, every statement in the block, except possibly the last one, has exactly one successor. • An arc a in A is a pair (n,m) of nodes from N which represent transfer of control from node n to node m. • A path of length k in G is an ordered sequence of arcs, from A such that: Test assessment and improvement

  33. Control flow graph-continued • The first node in is en • The last node in is ex • For any two adjacent arcs = (n,m) and = (p,q), m=p. • A path is considered executable or feasible if there exists a test case which causes this path to be traversed during program execution, otherwise the path is unexecutable or infeasible. Test assessment and improvement

  34. Control flow graph-example Class exercise: Draw a CFG for the following program: 1. scanf (x,y); if (y<0) 2. pow=0-y; 3. else pow=y; 4. z=1.0; 5. while (pow !=0) 6. {z=z*x; pow=pow-1;} 7. if (y<0) 8. z=1.0/z; 9. printf(z); What does the above program compute? Test assessment and improvement

  35. Control flow graph-example Class exercise: For the CFG you have drawn, list all paths of length at most 10. Are there more paths than what you have listed? What does the above program compute? Test assessment and improvement

  36. Structure-based test adequacy • Based on the CFG of a program several test adequacy criteria can be defined. • Some are: • statement coverage criterion • branch coverage criterion • condition coverage criterion • path coverage criterion Test assessment and improvement

  37. Statement coverage • The coverage domain consists of all statements in the program. Restated, in terms of the control flow graph, it is the set of all nodes in G. • A test T satisfies the statement coverage criterion if upon execution of P on each element of T, each statement of P has been executed at least once. Test assessment and improvement

  38. Statement coverage-continued • Restated in terms of G, T is adequate w.r.t. the statement coverage criterion if each node in N is on at least one of the paths traversed when P is executed on each element of T. Test assessment and improvement

  39. Statement coverage-continued • Class exercise: • For the program for which you have drawn the control flow graph, develop a test set that satisfies the statement coverage criterion. • Follow the procedure for test assessment and improvement suggested earlier. Test assessment and improvement

  40. Statement coverage-weakness • Consider the following program: int abs (x); int x; { if (x>=0) x=0-x; return x; } Test assessment and improvement

  41. Statement coverage-weakness • Suppose that T= {(x=0)}. • Clearly, T satisfies the statement coverage criterion. • But is the program correct and is the error revealed by T which is adequate w.r.t. the statement coverage criterion? What do you suggest we do to improve T? Test assessment and improvement

  42. Branch (or edge) coverage • In G there may be nodes which correspond to conditions in P. Such nodes, also called condition nodes, contain branches in P. • Each such node is considered covered if during some execution of P, the condition evaluates to true and false; these executions of P need not be the same. Test assessment and improvement

  43. Branch coverage • The coverage domain consists of all branches in G. Restated, in terms of the control flow graph, it is the set of all arcs exiting the condition nodes. • A test T satisfies the branch coverage criterion if upon execution of P on each element of T, each branch of P has been executed at least once. Test assessment and improvement

  44. Branch coverage • Class exercise: • Identify all condition nodes in the flow graph you have drawn earlier. • Does T= {(x=0)} satisfy the branch coverage criterion? • If not, then improve it so that it does. Test assessment and improvement

  45. Branch coverage-weakness • Consider the following program which is suppose to check that the input data item is in the range 0 to 100, inclusive: int check(x); int x; { if ((x>=0 )&& (x<=200)) check=true; else check=false; } Test assessment and improvement

  46. Branch coverage-weakness • Class exercise: • Do you notice the error in this program? • Find a test set T which is adequate w.r.t. statement coverage and does not reveal the error. • Improve T so that it is adequate w.r.t. branch coverage and does not reveal the error. • What do you conclude about the weakness of the branch coverage criterion? Test assessment and improvement

  47. Condition coverage • Condition nodes in G might have compound conditions. • For example, in the check program the condition node contains the condition: • This is a compound condition which consists of the elementary conditions x>=0 and x<=200. ((x>=0 ) && (x<=200)) Test assessment and improvement

  48. Condition coverage-continued • A compound condition is considered covered if all of its constituent elementary conditions evaluate to true and false, respectively, during some execution of P. • A test set T is adequate w.r.t. condition coverage if all conditions in P are covered when P is executed on elements of T. Test assessment and improvement

  49. Condition coverage-continued • Class exercise: • Improve T from the previous exercise so that it is adequate w.r.t. the condition coverage criterion for the check functionand does not reveal the error. • Do you find the above possible? Test assessment and improvement

  50. Branch coverage-weakness, continued • Consider the following program: 0. int set_z(x,y); { 1. int x,y; 2. if (x!=0) 3. y=5; 4. else z=z-x; 5. if (z>1) 6. z=z/x; 7. else 8. z=y; } What might happen here? Test assessment and improvement

More Related