Mutation testing is a structural testing approach used to check the efficiency or precision of a testing program. This method helps to check the number of defects in an application under test. It also helps in estimating or boosting the adequacy of test suites.
Why It Is Named As Mutation Testing?
Mutation testing is named so, as mutants (small change in the program) are created and introduced into the program code. This strategy is also known as fault-based testing method as the mutants are created by introducing a single defect into the original program code.
Why Mutation Testing Need To Be Performed?
Test coverage is considered as an important factor in software testing. Mutation testing helps to analyze if a set of testing strategies are enough to ensure that the product meets quality requirements. If we are not able to get hold of any issues, we can’t guarantee that the system will be bug free.
In mutation testing, a minor change is made in the software code. After this, a set of test cases are checked against the mutated program. Good unit testing will be able to check the defects in the program code.
How To Perform Mutation Testing?
- Create mutant software- Mutant of the program need to be created initially by introducing a single defect into the AUT. QA testers can introduce as many mutants as required. They also need to ensure that every mutant remains unique and is also different from the original system.
- Test case preparation – QA team should be able to craft test case in such a way that it is able to identify the issues caused by mutant.
- Test the original software – QA testers need to check if the output of the test cases given to the input software remains same as the anticipated result. Else, issues need to be fixed and software need to be tested till the AUT is free from defects.
- Mutant software testing – Mutant software need to be tested with the same set of test cases as the original software. If the output of mutant software differs from that of original software, mutant need to be marked as dead. It should not be tested again.
- Mutation score calculation – It is defined as the ratio of count od dead mutants to that of non equivalent mutants. Ideal value of Mutation score is 1.
- Mutation score analysis – Mutation score is directly related to testing efficiency. QA tester can repeat mutation testing till a satisfactory result is obtained.
Mutation Testing Types:
Mutation testing can be broadly classified into three – Value mutation, decision mutation and statement mutation.
In value mutation, value of constants or parameters are changed. For example, value is changed to one larger or one smaller in loops, Initialization value is changed.
Decision mutation – This helps to modify program code so that slip errors are reflected. For example, > a is changed to <a.
Statement mutation – In this type of testing, developer cuts and paste codes which might result in deletion of some statements of lines. This may also involve swapping the order of line of code. A line of code can be deleted/duplicated. Order of statements can also be changed.
The operators that are applied on the original program to generate the mutants are known as Mutation operators. The Mutation operators can be broadly classified into
- Traditional mutation operators
- Class mutation operators
Traditional Mutation Operators:
The traditional mutation operators are developed for procedural programming language. Though application of these operators generate a large number of mutants, all of them may not be effective as they tend to overlap. The following are the traditional mutation operators
- Arithmetic Operators
- Relational Operators
- Conditional Operators
- Logical Operators
- Assignment Operators
- Shift Operators
The mutants are generated by replacing, inserting or deleting the mutant operators.
Class Mutation Operators:
These are used for generating mutants to test object -oriented and integration issues.
- Encapsulation -Mutants are formed by application of operators that modifies, deletes or insert the access level for instance variables and methods.
- Inheritance – The mutants are produced by application of operators that deletes a hiding variable to check whether that variable is defined and that its accessibility in class and subclasses are correct.
- Polymorphism – The mutants are created by the polymorphism operators to check if the methods having the same name and number of parameters are accessible in a right manner or not.
Mutation Testing Tools:
There are several Mutation testing tools that are available. Jumble and Insure++ are the most common among that.
- Jumble is a simple non-graphic open source tool. It converts the text files into version that enables studying the format of the file.
- It directly operates at a source code level and speed up the Mutation testing process. The limited sets of Mutation operators supported by Jumble are: Conditional, Binary Arithmetic Operations, Increments, Inline Constants, Class Pool Constants, Return Values, and Switch Statements
- It is a commercial automatic testing tool for C and C++ that makes use of Mutation analysis technique.
- Instead of generating all possible mutants, Insure++ focuses on the “potential equivalent mutants”. The motivation behind this idea is that if any test case is able to kill the “potential equivalent mutants”, it might also find the faults in the original program
Challenges Of Mutation Testing:
Mutation testing is able to effectively assess the adequacy and quality of a test set but it also has certain challenges as below
- Mutation testing has a high computational cost of executing the enormous number of mutants against a test set.
- The human oracle problem, which refers to the process of checking the output of each test case against the output of original program, can be a serious problem as mutation testing can lead to an increase in the number of test case
If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below: