advertisement

About the weak killing of mutants An attempt to clarify the two examples Example 1: int Min (int A, int B) { int minVal = A; 1 int minVal = B; if (B < A) minVal = B; return minVal; // Reachability: true // Infection: B ≠ A // Propagation: B > A } • Propagation is only about the result (and possible side effects in the general case): whether it is different with the mutant than the original method. • It does not matter in principle whether the control flow after the infection is the same or different than in the original method. Looking at this can at most help in checking for propagation. • The question about propagation is vacuous when there is no infection, i.e., no erroneous state to propagate. Thus, one can say (as in the book and slide) that the propagation condition is ‛B ≥ A’ , but in my opinion that makes the idea more difficult to understand. 1 Example 2: boolean isEven (int X) { if (X < 0) X = 0 – X; X = 0; // Reachability: X < 0 // Infection: X ≠ 0 if ((float)(X / 2) == ((float)X / 2.0)) return true; // Propagation? else return false; // Propagation? } • Because infection always happens when the mutated statement is executed, we might as well consider the infection condition to be ‛true’. • The ‛if ’ condition is true when X is even, and false when X is odd. This is perhaps the most difficult thing to prove here. • The above also happens to mean that the original method is correct, but that would not be the business of the mutation-testing stage! • Because 0 is even, propagation happens if and only if the original value of X was odd (and negative). • In summary, an odd and positive test case will kill the mutant weakly, but not strongly. 2