written 7.7 years ago by | • modified 7.7 years ago |
Mumbai University > Information Technology> Sem 8 > Software Testing Quality Assurance
Marks: 10M
Year: Dec 2016
written 7.7 years ago by | • modified 7.7 years ago |
Mumbai University > Information Technology> Sem 8 > Software Testing Quality Assurance
Marks: 10M
Year: Dec 2016
written 7.7 years ago by |
Mutation testing
• Mutation testing is a technique that focuses on measuring the adequacy of test data (or test cases).
• The original intention behind mutation testing was to expose and locate weaknesses in test cases.
• Thus, mutation testing is a way to measure the quality of test cases, and the actual testing of program units is an added benefit.
• Mutation testing is not a testing strategy like control flow or data flow testing. It should be used to supplement traditional unit testing techniques.
• The mutations introduced to the source code are designed to imitate common programming errors.
• A good unit test suite typically detects the program mutations and fails automatically.
• Mutation testing is used on many different platforms , including Java, C++, C# and Ruby.
• Mutation testing facilitates the following advantages :
Program code fault identification
Effective test case development
Detection of loopholes in test data
Improved software program quality
Elimination of code ambiguity
• Mutant: A mutation of a program is a modification of the program created by introducing a single, small, legal, syntactic change in the code. A modified program so obtained is called a mutant.
• Killed mutant: A mutant is said to be killed when the execution of a test case causes it to fail and the mutant is considered to be dead.
• Equivalent mutants: Some mutants are equivalent to the given program, that is, such mutants always produce the same output as the original program.
• Killable or stubborn mutants: The result of executing a mutant may be different from the expected result, but a test suite does not detect the failure because it does not have the right test case. In this scenario, the mutant is called killable or stubborn, that is, the existing set of test cases is insufficient to kill it.
• Mutation Score :
A mutation score for a set of test cases is the percentage of non-equivalent mutants killed by the test suite.The test suite is said to be mutation adequate if its mutation score is 100 %.
Mutation Score is given by :
Mutation Score = 100 * D/(N-E)
Where D is the dead mutants, N is the total number of mutants and E is the number of equivalent mutants.
• The following example illustrates the concept of mutation testing:
Program to find the greatest of three numbers:
inta,b,c ;
if( a>b && a > c)
{
System.out.println (“ The greatest number is “ +a);
}
else if ( b>c)
{
System.out.println (“ The greatest number is” +b);
}
else
{
System.out.println(“ The greatest number is “ +c);
}
The following table identifies the killed and killable mutants for the above program:
Mutant | Test case | Input | Original Output | Mutant output | Test result | Verdict | ||
---|---|---|---|---|---|---|---|---|
M1: if(c > a && c < b) | 1 | <1,2,3> | 3 | Program terminates | Pass | Killed | ||
2 | <1,1,1> | 1 | Program terminates | Pass | Killed | |||
M2: if(a == b && a > c) | 1 | <1,2,3> | 3 | 3 | Failed | Killable | ||
2 | <1,1,1> | 1 | Program terminates | Pass | Killed | |||
M3: if(a > b | a > c) | 1 | <1,2,3> | 3 | 3 | Failed | Killable | |
2 | <1,1,1> | 1 | Program terminates | Pass | Killed | |||
M4: if(a > b && a > c) ; System.out.println("The greatest no is +c") | 1 | <1,2,3> | 3 | 3 | Failed | Killable | ||
2 | <1,1,1> | 1 | Program terminates | Pass | Killed | |||
M5: if(b >= a && b > c) | 1 | <1,2,3> | 3 | 3 | Failed | Killable | ||
2 | <1,1,1> | 1 | Program terminates | Pass | Killed |
**D: NO OF MUTANTS KILLED
N: Total no of mutants
E: No.of equivalent mutants**
Mutation Score
= 100 * D/(N-E)
=100 *5/(5-0)
=100