Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mutation Testing Tutorial Answers

Similar presentations


Presentation on theme: "Mutation Testing Tutorial Answers"— Presentation transcript:

1 Mutation Testing Tutorial Answers
1. What is an equivalent mutant and why are equivalent mutants a problem? 2. For the program fragment x= x+y; give five examples of mutants which are equivalent and five which are not equivalent 3. Give examples of test cases which kill your five non-equivalent mutants 4. Now make up some simple program fragments and try to think of some more stubborn mutants of these fragments. That is, mutants which are hard to kill but which are not equivalent.

2 Equivalent mutant An equivalent mutant is one which cannot be killed by any test case because it gives identical output to the original program for every possible input. That is, it is possible to create a syntactic variant of a program (a mutant) which is syntactically different to the original, but which behaves identically to it. This is a problem because one cannot tell whether the failure of test data to kill a mutant stems from inadequate test data or the fact that the mutant is equivalent.

3 Equivalent mutants x = x + y ; is equivalent to:- x = y + x ;
x = -z + x + y + z ; x = x+ (1==1)?y:z ; x = 2*x + y – x ; x = x + y + 0 ;

4 Non Equivalent mutants
x = x + y ; is not equivalent to:- x = y * x ; x = x + z ; x = x - y; x = x + 1 ; x = 2 + y ;

5 Killing the Non Equivalent mutants
x = y * x ; is killed by anything other than y=2, x=2 x = x + z ; is killed by any non-equal values for y and z x = x - y; is killed by any non zero value for y x = x + 1 ; is killed by any value of y other than 1 x = 2 + y ; is killed by any value of x other than 2

6 Stubborn mutant Consider if (a==b) then z=1; else z=2;
Suppose we mutate this to if (a==b+1) then z=1; else z=2; This is only killed by test cases where a and b are equal or where b one more than a.


Download ppt "Mutation Testing Tutorial Answers"

Similar presentations


Ads by Google