
Software Testing - Mutation Testing
A software undergoes various stages of testing in order to deliver the desired performance. The mutation testing is a type of testing that is conducted to build new test cases, and to analyze the quality of the already available test cases developed for verifying the software.
What is Software Mutation Testing?
Software mutation testing is also called code mutation testing. It is a concept under the white box testing technique. During this time, small changes in the code are made to verify the effectiveness of already available test cases, or to identify weaknesses in the test data utilized in the program source code.
The software mutation testing can be used to validate the design models, databases, XML etc. It is a kind of structural testing, where the anatomy of the code is used to help the process of testing. It basically rewrites the code in minor ways so that code redundancy can be avoided or minimized. After making updates in the source code, it is expected that the existing test cases identify them. The changes in the code usually result in the introduction of errors.
The mutation testing is mostly used to evaluate the effectiveness of the software testing tool rather than the software itself. It is mostly used at the time of unit testing. It catches defects which remain undetected by other testing methods. While performing the mutation testing, a line of code may be removed or used more than once, true or false statements or variables may be modified etc. Once the mutations in the code are incorporated, they are verified, and compared with the actual code.
In case the existing test cases running on the mutation code identify the same defects as when they are run against the original code, then either the code remains unexecuted or the existing test cases have not been able to identify the mutations. It then indicates that the existing test cases need to be worked upon to make them more productive. A successful mutation testing results should have different test results when the same test cases are executed against the original code, and the mutation code. When the test outcomes from the mutation code, and the original code are different, then the mutants are no longer used, these are known as the killed mutants.
Formula to Calculate the Mutation Score Percentage
The mutation score can be calculated by dividing the total count of mutants killed with the total count of mutants, and then multiplied by hundred.
Mutation Score = (Total count of mutants killed/ Total count of mutants) * 100
If we obtain a mutation score of hundred percent it indicates that the existing test cases are effective, and sufficient.
Objectives of Software Mutation Testing
The objectives of the software mutation testing are listed below −
- The software mutation testing validates the sections of the code which are not yet verified.
- The software mutation testing identifies the defects in the code which are not detected by following other testing methods.
- The software mutation testing detects new kinds of issues in the code.
- The software mutation testing measures the mutation score of the code.
- The software mutation testing gives an idea of the effectiveness of the existing test suites.
Types of Software Mutation Testing
The different types of the software mutation testing are listed below −
1. Value Mutations
In this type, the values of the constants are modified to identify issues in the code. A minor update is made on a very big value or a big value is updated to a smaller value. For example −
int i = 100000089; int j = 5678; int k = 91011; int c = (j * k) % i; Updated Code: int i = 1089; int j = 5678; int k = 91011; int c = (j * k) % i;
2. Decision Mutations
In this type, the logical or arithmetic operators are updated to identify issues in the program source code. For example −
if(i = j) k = 35; else k = 50; Updated Code: if(i != j) k = 35; else k = 50;
3. Statement Mutations
In this type, a statement is removed or replaced by another statement. For example −
if(i = j) k = 35; else k = 50; Updated Code: if(i != j) m = 35; else m = 50;
Tools used for Software Mutation Testing
The various tools used for the software mutation testing are listed below −
- PIT
- Insure
- Jester
- Jumble
- MuClipse
Advantages of Software Mutation Testing
The advantages of the software mutation testing are listed below −
- The software mutation testing increases the level of error identification in the program source code.
- The software mutation testing helps to get rid of unclear sections of the code.
- The software mutation testing detects and resolves issues in the code.
- The software mutation testing gives guidance to design or automate better and more effective test cases.
- The software mutation testing improves the level of programming used in the code.
Disadvantages of Software Mutation Testing
The disadvantages of the software mutation testing are listed below −
- The software mutation testing is a costly and time consuming process.
- The software mutation testing is only applicable to white box, and cannot be applied to black box testing technique.
- Sometimes the mutants are complicated, and hence not easy to design and execute them against the existing test suite.
- The testers performing the software mutation testing should be experienced, and should have programming, and technical skills.
- It is not easy to select the correct automation tool for carrying out the mutation testing.
Conclusion
This concludes our comprehensive take on the tutorial on Software Mutation Testing. Weve started with describing what is software mutation testing, formula to calculate the mutation score percentage, what are the objectives of the software mutation testing, what are the different types of the software mutation testing, what are the various tools used for software mutation testing, what are the advantages of software mutation testing, what are the disadvantages of software mutation testing. This equips you with in-depth knowledge of Software Mutation Testing. It is wise to keep practicing what youve learned and exploring others relevant to Software Testing to deepen your understanding and expand your horizons.