What is Mutation Testing in software testing?

Mutation testing is a kind of white box testing technique which examines the quality of the existing application. In mutation testing slightly syntactic changes are done in the source code and the result of the software is examined whether the test cases which are executed can find the errors.

The changes which are made in the source code is very small so that if the test case fails it does not affect the entire application. After applying the changes to the source code the test cases are again executed to evaluate the result of the mutated code. If the result of the original code and the mutated code is same then the mutation is said to be killed. Mutation testing is also called as the fault testing.

The following are the steps to implement the mutation testing:

  •  Some of the changes are introduced to the source code by creating many of its version which are known as the mutants.
  •  Test cases are designed to the original code and also to the mutant code.
  • Both kind of test cases are executed.
  • Results are compared and examined.
  • If the output generated by the original source code and the mutant source code is same then the mutant is said to be killed.

If the results of both the source code are different then the mutant is said to be kept alive.

mutation testing in software testing

There are three types of mutation testing as follows:

1. Value mutation
2. Condition mutation
3. Statement mutation

1. Value mutation:

In value mutation some of the values are changed to find out the errors and examine the result.

2. Condition mutation:

In condition mutation some of the conditions or decisions are changed to find out the errors and examine the result.

Here we can assume the arithmetic or relational operators which can be mutated.

e.g: { if (x && y) {…..} } => { if (x || y) {…..} } here the ‘&&’ operator is modified with ‘||’ operator

3. Statement mutation:

In statement mutation some of the lines from the source code can be deleted to evaluated the result or some of the lines can be duplicated.

Advantages of mutation testing:

  • This kind of testing is done to remove the redundancies of the application.
  • The working technique of mutation testing is simple to understand.
  • Can be used to find out the hidden errors.

Disadvantages of mutation testing:

  • Its a time consuming process.
  • If test cases are large then large number of mutant test cases need to be designed.
Share This: