The article is based on a post on the Cross Join telegram channel .
Before talking about this approach, I will first explain in a nutshell what mutation testing is in general. For those who are not in the know.
Mutation testing
When you write tests, TDD or not, even with a formal 100% coverage, you will never be sure that everything is actually tested in the code. For example, you can make a corny mistake in calling assert in the test itself.
assertEquals($a, $a);
And if even during testing it was possible to reach some if, it is not a fact that all conditions in this if are correctly checked.
To make sure that the tests are actually being tested, there is such a way: to introduce bugs into the code yourself, and see if the tests fall out of this. If the tests are still green with an obvious bug, then not everything has been tested.
For example, you changed the plus to a minus, or added "not" to the condition, and see if the tests reacted. This approach is called "Mutation Testing".
This is usually done in very critical areas of programming, where mistakes are generally not allowed. For example, rover software or medical software.
Of course, in rover construction, this is all done automatically: a special tool disfigures your program and looks to see if the tests have failed.
, , , , , . : AST, .
Mutation Driven Development
mutation driven development. TDD, .
- , ( )
- ( if). , , MDD (?) , 100% overage TDD.
, CI, , , MDD .
, , . mutation driven testing , . , .. , , , , , ., 95% , - -. , .
We'll of course discuss mutation driven development in one of the upcoming Zinc Sales , don't forget to subscribe to the podcast