Suppose you are writing a big chunk of code. You have decided to run both unit and mutation tests. Your score of unit tests is 100% and mutation 99%. You think "I'll make that 100%". After some work, you notice this part of your code:
Let's analyse this example.
a.comma is greater than
b.comma. For example 4 and 2
We get that
if we change
>= sign in our source code to
<= it won't work, so our mutant is killed.
If we change 4 and 2 to 3 and 5, we will get the same output: mutant will be killed. But what if we have both values the same? Let's say: 3, 3
Notice that 10 ** 0 = 1, so even if we change
<= and even
> we will get the same output each time!
It is called equivalent mutant. There is no definitive way for Stryker to find and ignore them. There is currently also no way yet to mark them to be ignored.
For now, the only solution is by finding these by hand, which is time consuming and try to rewrite the code so it won't occur, or accept that you won't make 100%.
First one has been shown above. The easiest schema for this mutant is:
The second one we have found is about
-0n is transformed to
will produce another equivalent mutant.
So knowing that for now, help us find more of them and don't be scared of not 100% mutation score!