https://www.techtarget.com/searchitoperations/definition/mutation-testing
Mutation testing, also known as code mutation testing, is a form of white box testing in which testers change specific components of an application's source code to ensure a software test suite can detect the changes. Changes introduced to the software are intended to cause errors in the program. Mutation testing is designed to ensure the quality of a software testing tool, not the applications it analyzes.
Mutation testing is typically used to conduct unit tests. The goal is to ensure a software test can detect code that isn't properly tested or hidden defects that other testing methods don't catch. Changes called mutations can be implemented by modifying an existing line of code. For example, a statement could be deleted or duplicated, true or false expressions can be changed or other variables can be altered. Code with the mutations is then tested and compared to the original code.
If the tests with the mutants detect the same number of issues as the test with the original program, then either the code has failed to execute, or the software testing suite being used has failed to detect the mutations. If this happens, the software test is worked on to become more effective. A successful mutation test will have different test results from the mutant code. After this, the mutants are discarded.
The software test tool can then be scored using the mutation score. The mutation score is the number of killed mutants divided by the total number of mutants, multiplied by 100.
Mutation score = (number of killed mutants/total number of mutants killed or surviving) x 100
A mutation score of 100% means the test was adequate.
A mutation is a small syntactic change made to a program statement. Mutations typically contain one variable that causes a fault or bug. For example, a mutation could look like the statement (A<B) changed to (A>B).
Testers intentionally introduce mutations to a program's code. Multiple versions of the original program are made, each with its own mutation, or mutants. The mutants are then tested along with the original application. After testing, testers compare the results to the original program test.
Once the testing software has been fixed, the mutants can be kept and reused in another code mutation test. If the test results from the mutant code to the original programs are different, then the mutants can be discarded, or killed.
Mutants that are still alive after running the test are typically called live mutants, while those killed after mutation testing are called killed mutants. Equivalent mutants have the same meaning as the original source code even though they have different syntax. Equivalent mutants aren't calculated as part of the mutant score.
There are three main types of mutation testing:
Code mutation provides the following advantages:
Disadvantages of code mutation include the following:
Mutation testing tools can help speed up the mutant generation process. The following are examples of open source mutation testing tools:
A mutation testing tool can be used to run unit tests against automatically modified code. Tools can also create reports that show killed and live mutations as well as no coverage, timeouts, memory and run errors.
Mutation tests are typically completed using the following steps.
At first glance, regression testing could be confused with mutation testing. Regression testing tests new changes to a program to ensure the older program still works with these changes. Test department coders develop code test scenarios that test new units of code after being written.
While regression testing is used to test if new changes to a program causes an issue, mutation tests make small changes to code to ensure a software test works as intended.
Learn more about regression testing and what to consider when choosing regression testing tools.
14 Apr 2023