0
13kviews
Explain mutation testing with help of an example

Similar questions

1) Explain the concept of Mutation testing. What are the assumptions made in Mutation testing?

2) Explain with suitable example the concepts of mutation testing, mutant, mutation score,killable mutant and stubborn mutant. What do you mean by equivalent mutant?

Marks: 6/10 M

Year: Dec 2011, Dec 2012 ,Dec 2013, May 2014

1 Answer
1
499views

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 :

  1. Program code fault identification

  2. Effective test case development

  3. Detection of loopholes in test data

  4. Improved software program quality

  5. 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:

enter image description here

**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

Please log in to add an answer.