Showing posts from February, 2021

Mutation Testing with Stryker

This is a first look into Stryker Mutator . As for what it does; you might have already done this yourself, albeit manually, when reviewing someones PR. You’re considering how effective a given test is, so you pull the code and run the tests, and sure enough, you see the test pass and 100% code coverage. You’re still not convinced so you tweak the code in some minor way, expecting the test to fail. Surprise! It still passes and you still have 100% code coverage! So this is a bad set of tests! So what is Stryker Mutation testing? Consider the following example code (taken from the stryker docs ). function isUserOldEnough ( user ) { return user . age >= 18 ; } When Stryker is run against this code base, it will automatically mutate the return statement, recompile your application, and re-run the tests. For every mutation that Styker tries, a test MUST fail, otherwise we have a mutant. Here’s what mutations Stryker will make here: /* 1 */ return user . age &g