Tag Mutational Testing

Mutational tests
3 min read

When you have a very simple application it’s not so important to test every edge case but in a project, in the very complex domain, the priority of it will increase. The more high-quality the tests, the more high-quality the code. Mutational tests will help you with making sure you did not miss some a variant of the flow in your code.

How it works

  • Mutational testing is a test which runs other test several times but with a bit changed production code in every iteration. Everything happens on the fly. The idea behind it is to check if your test will fail if you change something in your production code.
  • Runs Tests without modifications. The tests should be green here.
  • Parses the whole production code to find places where it can make a change.
  • For every small change runs tests again and one of your tests should fail.
  • If one of the mutations fail, the whole mutational test fails, too.
  • Otherwise, the test succeeded.

I’ll show it in an example when it may be useful. Imagine you have a code like the above.