Mutation testing is a kind of testing in which, the application is tested for the code that was modified after fixing a particular bug/defect. It also helps in finding out which code and which strategy of coding can help in developing the functionality effectively. You can refer the Mutation testing Pdf training tutorials after reading this tutorial.
Mutation testing ensure the accuracy of our unit tests.In some cases our unit tests will be successful and won’t detect any bugs or defects in our source code, but that may be not true. In this situations, we will do some alteration in source code (mutating) for making errors and again will run those unit test.Now if our unit tests are perfect then it will catch the defect in mutated code.Otherwise we can understand that our unit tests are not proper. So simply we can say that Mutation Testing is a testing of our tests.
Basics
Mutation testing is a technique by which test examples can be improved. The term mutation refers to the change in the program.
Mutation is an operation by which we make small changes in code of a program. If we mark the original program as P, M is a mutant of that program, and P is a parent of program M. Given the fact that program P must be syntactically accurate, the M program must be as well. It is also possible to make a mutant by adding new code in the original program.
Sorts of mutations
Mutants that have only one change in relation to tested program are called first-order mutants.
Second-order mutants are formed by making two simple changes in a program and also from the first-order mutants, while third-order mutants are formed by making three simple changes in a program and so on.
With exception of first-order mutants, all the others are called higher-order mutants.
So, what is mutation testing?
Mutation testing is by definition a criterion of testing: the tests are either generated by accident until the enough number of mutations are killed, or the tests are designed to purposely kill surviving mutations. In the latter case, testing of mutations can be categorized as a code based technique. For this technique to be effective, a great number of mutants must be produced in a systematic way. If the testing is successful in determining a difference between a program and a mutant, the another one is killed.
Mutation score
Depending on the set of test examples we choose and programs we test, we can calculate mutation score. This score represents a quantified estimation of the quality of the set of test examples. It is a number between 0 and 1. The score 1 means that the set of test examples is adequate, while the score less than 1 represents that this set is inadequate.
Inadequate set of tests can be improved by adding tests examples that can make the mutation result better.
Some more facts about Mutation testing
- Richard Lipton is the man who introduced this testing first.
- Timothy Budd implemented the first Mutation testing tool.
- Mutation testing will be very expensive for large applications without using any tools.
- While mutating the source code, normally small changes on variables and operands are performing.