Mutation Testing
It is one thing to use the many techniques to come up with a set of test. There is software that will go through you code and test cases and provides a measure which show how much of your code is actually covered by the tests. This is a great start but how do you know if your tests are really helpful. That is to say are do the test do a good job at testing the code and would they pick up on errors. To really judge how strong your test suite is you need to be able to test your test. One way of doing this is by purposely making changes to your code and seeing if your tests catch it. This is called mutation testing.
Manually going through your code would be very time consuming and tedious. The benefits would not be worth the effort. Luckily there are programs that automate this process. I personally looked at Pit Mutation Testing. It can be found at pitest.org. In the case of Pitest it works with Java and the software directly modifies the byte code which makes the process much faster as you don’t need to edit the source then recompile.
The code systematically works through the code and makes changes, these changes are referred to as mutants. It then runs the tests to see if these mutants survive or are killed. It then generates a report that shows what lines are covered by the test as well as what mutations it generated. For each mutation it will show if it survived or was killed. In the case of a surviving mutation it will indicate whether it was tested and survived or if it was simply never tested.
Some of the mutation it tries include changing logical operators, changing the the operations in equations and returning null.
these changes include changes logical statements.
From the blog CS@WSU – :(){ :|: & };: by rmurphy12blog and used with permission of the author. All other rights reserved by the author.