Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS 406 Fall 98 Software Testing Part III: Test Assessment and Improvement Aditya P. Mathur Purdue university Last update: July 19, 1998."— Presentation transcript:

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

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

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

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

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

6 Test assessment and improvement6 Test assessment-continued 4 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.

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

8 Test assessment and improvement8 Test assessment-continued 4 This is continued until all weaknesses are overcome, i.e. the adequacy criterion is satisfied (coverage=1). 4 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.

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

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

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

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

13 Test assessment and improvement13 The coverage principle 4 To formulate and understand the coverage principle, we need to understand: –coverage domains –coverage elements 4 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

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

15 Test assessment and improvement15 The coverage principle-continued 4 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.

16 Test assessment and improvement16 The coverage principle-continued 4 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.

17 Test assessment and improvement17 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?

18 Test assessment and improvement18 The coverage principle-continued 4 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?

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

20 Test assessment and improvement20 Test effort 4 There are several measures of test effort. 4 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.

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

22 Test assessment and improvement22 Effectiveness-continued 4 Another measure is the probability that at least fraction f of the faults in P will be revealed by test T that satisfies C. 4 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.

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

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

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

26 Test assessment and improvement26 The Saturation Effect 4 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. coverage01

27 Test assessment and improvement27 Saturation Effect: Fault View Testing Effort Remaining Faults 0 N M Functional tfstfs tfetfe tdstds t df e tmetme

28 Test assessment and improvement28 Saturation Effect: Reliability View FUNCTIONAL, DECISION, DATAFLOW AND MUTATION COVERAGE PROVIDE VARIOUS TEST EVALUATION CRITERIA. Reliability Testing Effort True reliability (R) Estimated reliability (R’) Saturation region Mutation Dataflow Decision Functional RmRm R df RdRd RfRf R’ f R’ d R’ df R’ m tfstfs tfetfe tdstds tdetde t df s t df e tmstms tfetfe

29 Test assessment and improvement29 Coverage principle-discussion 4 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?

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

31 Test assessment and improvement31 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.

32 Test assessment and improvement32 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:

33 Test assessment and improvement33 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.

34 Test assessment and improvement34 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?

35 Test assessment and improvement35 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?

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

37 Test assessment and improvement37 Statement coverage 4 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. 4 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.

38 Test assessment and improvement38 Statement coverage-continued 4 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.

39 Test assessment and improvement39 Statement coverage-continued 4 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.

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

41 Test assessment and improvement41 Statement coverage-weakness 4 Suppose that T= {(x=0)}. 4 Clearly, T satisfies the statement coverage criterion. 4 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?

42 Test assessment and improvement42 Branch (or edge) coverage 4 In G there may be nodes which correspond to conditions in P. Such nodes, also called condition nodes, contain branches in P. 4 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.

43 Test assessment and improvement43 Branch coverage 4 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. 4 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.

44 Test assessment and improvement44 Branch coverage 4 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.

45 Test assessment and improvement45 Branch coverage-weakness 4 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; }

46 Test assessment and improvement46 Branch coverage-weakness 4 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?

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

48 Test assessment and improvement48 Condition coverage-continued 4 A compound condition is considered covered if all of its constituent elementary conditions evaluate to true and false, respectively, during some execution of P. 4 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.

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

50 Test assessment and improvement50 Branch coverage-weakness, continued 4 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?

51 Test assessment and improvement51 Branch coverage-weakness 4 Class exercise: Construct T for set_z such that (a) T is adequate w.r.t. the branch coverage criterion and (b) does not reveal the error. What do you conclude about the effectiveness of the branch and condition coverage criteria?

52 Test assessment and improvement52 Path coverage 4 As mentioned before, a path through a program is a sequence of statements such that the entry node of the program CFG is the first node on the path and the exit node is the last one on the path. Is this definition equivalent to the one given earlier?

53 Test assessment and improvement53 Path coverage-continued 4 A test set T is considered adequate w.r.t. the path coverage criterion if all paths in P are executed at least once upon execution on each element of T. 4 Class exercise: Construct T for set_z such that T is adequate w.r.t. the path coverage criterion and does not reveal the error. Is the above possible?

54 Test assessment and improvement54 Path coverage-weakness 4 The number of paths in a program is usually very large. 4 How many paths in set_z? 4 How many paths in check? 4 How many in the program that computes

55 Test assessment and improvement55 Path coverage-weaknesses 4 It is the infinite or a prohibitively large number of paths that prevent the use of this criterion in practice. 4 Suppose that a test set T covers all paths. Will it guarantee that all errors in P are revealed ? 4 Is obtaining 100% path coverage equivalent to exhaustive testing?

56 Test assessment and improvement56 Variants of path coverage 4 As path coverage is usually impossible to attain, other heuristics have been proposed. 4 Loop coverage: –Make sure that each loop is executed 0, 1, and 2 times. 4 Try several combinations of if and switch statements. The combinations must come from requirements.

57 Test assessment and improvement57 Hierarchy in Control flow criteria Path coverage Condition coverage Branch coverage Statement coverage X Y X subsumes Y.

58 Test assessment and improvement58 Exercise 4 Develop a test set T that is adequate w.r.t. the statement, condition, and the loop coverage criteria for the exponentiation program.

59 Test assessment and improvement59 Testing technique or strategy 4 One can develop a testing strategy based on any of the criteria discussed. 4 Example: –A testing strategy based on the statement coverage criterion will begin by evaluating a test set T against this criterion. Then new tests will be added to T until all the statements are covered, i.e. T satisfies the criterion.

60 Test assessment and improvement60 Definitions 4 Error-sensitive path: a path whose execution might lead to eventual detection of an error. 4 Error revealing path: a path whose execution will always cause the program to fail and the error to be detected.

61 Test assessment and improvement61 Definitions 4 Reliable: A testing technique is reliable for an error if it guarantees that the error will always be detected. –This implies that a reliable testing technique must lead to the exercising of at least one error- revealing path.

62 Test assessment and improvement62 Definitions 4 Weakly reliable: A testing technique is weakly reliable if it forces the execution of at least one error sensitive path.

63 Test assessment and improvement63 Example: error detection 4 Let us go over the example in Korel and Laski’s paper. 4 It is a sorting program which uses the bubble sort algorithm. 4 It sorts an array a[0:N] in descending order. 4 There are two, nested, loops in the program. 4 The inner loop from i6-i10 finds the largest element of a[R1:N].

64 Test assessment and improvement64 Example: error detection 4 The largest element is saved in R0 and R3 points to the location of R0 in a. 4 The outer loop swaps a(R1) with a(R3). 4 The completion of one iteration of the outer loop ensures that the sub-array a[0:R1-1] has been sorted and that a[R1-1] is greater than or equal to any element of a[R1:N].

65 Test assessment and improvement65 Example: error detection 4 There is a missing re-initialization of R3 to R1 at the beginning of the inner loop. 4 In some cases this will cause the program to fail. What are these cases? 4 We will get back to this error later!

66 Test assessment and improvement66 Class exercise 4 Is the path testing strategy reliable for the sort program and for the missing initialization error in it ? 4 Is it viable ? 4 What about the branch testing strategy? 4 What about loop testing?

67 Test assessment and improvement67 Data flow graph 4 It represents the flow of data in a program. 4 The graph is constructed from the control flow graph (CFG) of the program. 4 A statement that occurs within a node of the CFG might contain variables occurrences. 4 Each variable occurrence is classified as a def or a use.

68 Test assessment and improvement68 defs and uses 4 A def represents the definition of a variable. Here are some sample defs of variable x: x=y*x; scanf(&x,&y); int x; x[i-1]=y*x; 4 A use represents the use of a variable in a statement. Here a few examples of use of variable x: All defs of x are italicized.

69 Test assessment and improvement69 def-use-continued x=x+1; printf (“x is %d, y is %d”, x,y); cout << x << endl << y z=x[i+1] if (x<y)… 4 Uses of a variable in input and assignments are classified as c-uses. Those in conditions are classified as p-uses. All uses of x are italicized.

70 Test assessment and improvement70 def-use-continued 4 c-use stands for computational use and p- use for predicate-use. 4 Both c- and p-uses affect the flow of control: p-uses directly as their values are used in evaluating conditions and c-uses indirectly as their values are used to compute other variables which in turn affect the outcome of condition evaluation.

71 Test assessment and improvement71 def-use-continued 4 A path from node i to node j is said to be def-clear w.r.t. a variable x if there is no def of x in the nodes along the path from node i to node j. Nodes i and j may have a def of x. 4 A def-clear path from node i to edge (j,k) is one in which no node on the path has a def of x.

72 Test assessment and improvement72 global-def 4 A def of a variable x is considered global to its block if it is the last def of x within that block. 4 A c-use of x in a block is considered global c-use if there is no def of x preceding this c- use within this block.

73 Test assessment and improvement73 def-use graph: definitions 4 def(i): set of all variables for which there is a global def in node i. 4 c-use(i): set of all variables that have a global c-use in node i. 4 p-use(i,j): set of all variables for which there is a p-use for the edge (i,j). 4 dcu(x,i): set of all nodes such that each node has x in its c-use and x is in def(i).

74 Test assessment and improvement74 def-use graph: definitions 4 dpu(x,i): set of all edges such that each edge has x in its p-use, x is in def(i). 4 The def-use graph of program P is constructed by associating defs, c-use, and p-use sets with nodes of a flow graph. The next example is from Jalote’s text, pp425- 428.

75 Test assessment and improvement75 def-use graph-continued 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); Sample program:

76 Test assessment and improvement76 def-use graph-continued 1 23 6 5 4 7 89 def={x,y} c-use=  def={pow} c-use={y} def={pow} c-use={y} def={z} c-use=  def=  c-use=  def={z,pow} c-use={z,x,pow} def=  c-use=  def=  c-use={z} def={z} c-use={z} yy pow yy Unlabeled edges imply empty p-use set.

77 Test assessment and improvement77 def-use graph-class exercise 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; } Draw a def-use graph for the following program.

78 Test assessment and improvement78 def-use graph-continued 4 Traverse the graph to determine dcu and dpu sets. (node, var)dcudpu (1,x){6}  (1,y){2,3}{(1,2),(1,3),(7,8),(7,9)} (2,pow){6}{(5,6),(5,7)} (3,pow){6}{5,6),(5,7)} (4,z){6,8,9}  (6,z){6,8,9}  (6,pow){6}{(5,6),(5,7)} (8,z){9} 

79 Test assessment and improvement79 Test generation 4 Class exercises : –For the above graph generate a test set that satisfies the branch coverage criterion the all-defs criterion - for definitions of all variables at least one use (c- or p- use) must be exercised. the all-uses criterion- all p-uses and all c-uses of all variable definitions be covered. Develop the tests incrementally, i.e. by modifying the previous test set!

80 Test assessment and improvement80 Data flow testing tool 4 We will use  SUDS, a data flow testing tool developed at Bellcore and available commercially from IBM. 4 The acronym  SUDS stands for Software Understanding and Debugging System. 4  SUDS is a collection of tools of which  ATAC is the one that measures control flow and data flow coverage.

81 Test assessment and improvement81  ATAC processing: phase I P, Program under test Preprocess, compile and instrument. atac files Instrumented version of P (executable) Test set Program output. trace file upon execution generate input upon execution

82 Test assessment and improvement82  ATAC processing: phase II coverage analyzer.atac files.trace file control flow and data flow coverage values

83 Test assessment and improvement83  ATAC demo 4 Open DOS window. 4 Go to /Program Files/bellcore/xSUDS/tutorial 4 Type ataccl /Fedemo main.c wc.c 4 Type xsuds *.atac 4 You may now view program complexity statistics in the  suds window

84 Test assessment and improvement84  ATAC demo-continued 4 Go back to the DOS window and type: demo -c input1 4 Go to the xSUDS window and examine various coverage values. 4 Go back to the DOS window and type: demo -c input2 4 Go to the xSUDS window and examine how various coverage values have changed.

85 Test assessment and improvement85  ATAC demo-continued 4 Repeat the above steps of executing demo on several test inputs. Analyze coverage values and observe how they change with new test data. 4 Other tools in  SUDS will be discussed in the laboratory.

86 Test assessment and improvement86 Mutation testing 4 What is mutation testing? –Mutation testing is a code-based test assessment and improvement technique. –It relies on the competent programmer hypothesis which is the following assumption: Given a specification a programmer develops a program that is either correct or differs from the correct program by a combination of simple errors.

87 Test assessment and improvement87 Mutation testing-continued 4 The process of program development is considered as iterative whereby an initial version of the program is refined by making simple, or a combination of simple changes, towards the final version.

88 Test assessment and improvement88 Mutation testing-definitions 4 Given a program P, a mutant of P is obtained by making a simple change in P. 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; Program 1.int x,y; 2.if (x!=0) 3.y=5; 4.else z=z-x; 5.if (z>1) 6.z=z/zpush(x); 7.else 8.z=y; Mutant What is zpush?

89 Test assessment and improvement89 Another mutant 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; Program 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; Mutant

90 Test assessment and improvement90 Mutant 4 A mutant M is considered distinguished by a test case t  T iff: P(t)  M(t) where P(t) and M(t) denote, respectively, the observed behavior of P and M when executed on test input t. 4 A mutant M is considered equivalent to P iff: P(t)  M(t)  t  T.

91 Test assessment and improvement91 Mutation score 4 During testing a mutant is considered live if it has not been distinguished or proven equivalent. 4 Suppose that a total of #M mutants are generated for program P. 4 The mutation score of a test set T, designed to test P, is computed as: number of live mutants/(#M-number of equivalent mutants)

92 Test assessment and improvement92 Test adequacy criterion 4 A test T is considered adequate w.r.t. the mutation criterion if its mutation score is 1. 4 The number of mutants generated depends on P and the mutant operators applied on P. 4 A mutant operator is a rule that when applied to the program under test generates zero or more mutants.

93 Test assessment and improvement93 Mutant operators 4 Consider the following program: int abs (x); int x; { if (x>=0) x=0-x; return x; }

94 Test assessment and improvement94 Mutation operator 4 Consider the following rule: Replace each relational operator in P by all possible relational operators excluding the one that is being replaced. 4 Assuming the set of relational operators to be: {, =, ==, !=}, the above mutant operator will generate a total of 5 mutants of P.

95 Test assessment and improvement95 Mutation operators 4 Mutation operators are language dependent. 4 For Fortran a total of 22 operators were proposed. 4 For C a total of 77 operators were proposed. None have been proposed for C++ though most of the operators for C are applicable to C++ programs.

96 Test assessment and improvement96 Equivalent mutant 4 Consider the following program P: int x,y,z; scanf(&x,&y); if (x>0) x=x+1; z=x*(y-1); else x=x-1; z=x*(y-1); 4 Here z is considered the output of P.

97 Test assessment and improvement97 Equivalent mutant-continued 4 Now suppose that a mutant of P is obtained by changing x=x+1 to x=abs(x)+1. 4 This mutant is equivalent to P as no test case can distinguish it from P.

98 Test assessment and improvement98 Mutation testing procedure Given P and a test set T: 1. Generate mutants 2. Compile P and the mutants 3. Execute P and the mutants on each test case. 4. Determine equivalent mutants.. 5. Determine mutation score. 6. If mutation score is not 1 then improve the test set and repeat from step 3.

99 Test assessment and improvement99 Mutation testing procedure 4 In practice the above procedure is implemented incrementally. 4 One applies a few selected mutant operators to P and computes the mutation score w.r.t. to the mutants generated. 4 Once these mutants have been distinguished or proven equivalent, another set of mutant operators is applied.

100 Test assessment and improvement100 Mutation testing procedure 4 This procedure is repeated until either all the mutants have been exhausted or some external condition forces testing to stop. 4 We will not discuss the details of practical application of mutation testing.

101 Test assessment and improvement101 Tools for mutation testing 4 Mothra: for Fortran, developed at Purdue, 1990 4 Proteum: for C, developed at the University of Saõ Paulo at Saõ Carlos in Brazil.

102 Test assessment and improvement102 Uses of Mutation testing 4 Mutation testing is useful during integration testing to check for integration errors. 4 Only the variables that are in the interfaces of the components being integrated are mutated. This reduces the complexity of mutation testing.

103 Test assessment and improvement103 Summary 4 Test adequacy criterion 4 Test improvement 4 Coverage principle 4 Saturation effect 4 Control flow criteria 4 Data flow criteria –def, use, p-use, c-use, all-uses

104 Test assessment and improvement104 Summary continued 4 xSUDS, data flow testing tool. 4 Mutation testing –mutant, distinguishing a mutant, live mutant, mutant score, competent programmer hypothesis.


Download ppt "CS 406 Fall 98 Software Testing Part III: Test Assessment and Improvement Aditya P. Mathur Purdue university Last update: July 19, 1998."

Similar presentations


Ads by Google