Mutation Testing - Software Testing
Last Updated :
21 Jul, 2025
Mutation Testing is a white box Testing technique that helps compare the effectiveness of existing tests and design new ones. Making small modifications (mutations) in the source code, mutation testing aims to identify weaknesses in test cases and verify that all parts of the program are properly tested with their functionalities.
Mutation Testing was introduced by Richard Lipton in 1971. While the high cost initially limited its use, but now it is widely used in languages like Java and XML, proving its effectiveness in software testing.
The objective of mutation testing is:
- To identify pieces of code that are not tested properly.
- To identify hidden defects that can't be detected using other testing methods.
- To discover new kinds of errors or bugs.
- To calculate the mutation score.
- Understand how errors spread within the program.
- Assess how well the test cases perform.
Mutation TestingTypes of Mutation Testing
Mutation testing can be classified into three main types, based on the nature of the code changes:
1. Value Mutations
In this type of testing the values are changed to detect errors in the program. Basically a small value is changed to a larger value or a larger value is changed to a smaller value. In this testing basically constants are changed.
Initial Code:
int mod = 1000000007;
int a = 12345678;
int b = 98765432;
int c = (a + b) % mod;
Changed Code:
int mod = 1007;
int a = 12345678;
int b = 98765432;
int c = (a + b) % mod;
2. Decision Mutations
In decisions mutations are logical or arithmetic operators are changed to detect errors in the program.
Initial Code:
if(a < b)
c = 10;
else
c = 20;
Changed Code:
if(a > b) // Mutation: Reversed the condition
c = 10;
else
c = 20;
3. Statement Mutations:
In Statement Mutations, a statement is either deleted or replaced with another statement. This tests how the program handles changes to its flow.
Initial Code:
if(a < b)
c = 10;
else
c = 20;
Changed Code:
if(a < b)
d = 10; // Mutation: Replaced variable
else
d = 20;
Several tools are available for performing mutation testing, including:
- Judy
- Jester
- Jumble
- PIT
- MuClipse.
Advantages of Mutation Testing
Mutation Testing offers several benefits:
- It brings a good level of error detection in the program.
- It discovers ambiguities in the source code.
- It finds and solves the issues of loopholes in the program.
- It helps the testers to write or automate the better test cases.
- It provides more efficient programming source code.
Disadvantages of Mutation Testing:
Here are the few dis-advantages of mutation testing:
- It is highly costly and time-consuming.
- It is not able for Black Box Testing.
- Some, mutations are complex and hence it is difficult to implement or run against various test cases.
- Here, the team members who are performing the tests should have good programming knowledge.
- Selection of correct automation tool is important to test the programs.
Explore
Software Engineering Basics
Software Measurement & Metrices
Software Development Models & Agile Methods
SRS & SPM
Testing & Debugging
Verification & Validation
Practice Questions