Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is mutation testing useful in practice?

Do you have any examples of real life applications of mutation testing? Does it work better than simple test coverage tools? Or is it useless?

What are the advantages/disadvantages of mutation testing in the real world?

like image 367
Mnementh Avatar asked Oct 28 '08 09:10

Mnementh


People also ask

Is mutation testing useful?

Advantages to code mutation include: The ability to ensure the identification of weak tests or code. Has a high level of error detection. The increased use of object-oriented frameworks and unit tests have brought about more mutation testing tools.

Does mutation testing improve testing practices?

Our analyses suggest that developers using mutation testing write more tests, and actively improve their test suites with high quality tests such that fewer mutants remain.

Is mutation testing structural testing?

Mutation testing is a structural testing method, i.e. we use the structure of the code to guide the test process.


2 Answers

The usefulness of unit tests is no longer discussed. They are essential in conception of a quality application. But, how can we assess their relevance? A code coverage indicator up to 100% doesn’t mean the code is 100% tested. This is just a view of executed code during unit tests execution. Mutation testing will allow you to have more confidence in your tests.

This is a two step process:

  1. Generate mutants.
  2. Check that the mutations are found by the tests.

I wrote a entire article about this process, including some concrete cases.

like image 141
Nicolas De Nayer Avatar answered Sep 23 '22 12:09

Nicolas De Nayer


I looked at mutation test some time ago as a method for checking the efficacy of my automated regression testing scripts. Basically, a number of these scripts had missing checkpoints, so while they were exercising the application being tested correctly, they weren't verifying the results against the baseline data. I found that a far simpler method than changing the code was to write another application to introduce modifications to a copy of the baseline, and re-run the tests against the modified baseline. In this scenario, any test that passed was either faulty or incomplete.

This is not genuine mutation testing, but a method that uses a similar paradigm to test the efficacy of test scripts. It is simple enough to implement, and IMO does a good job.

like image 32
SmacL Avatar answered Sep 23 '22 12:09

SmacL