1

I am new to mutation testing. I use the Stryker library to generate and to run tests. But some mutations break the whole logic between code expressions. For example,

// real code

if (!(typeof age == 'number' && Math.trunc(age) == age)) throw new Error('age must be a whole number');

// mutated code from Stryker

if (!(true && Math.trunc(age) == age)) throw new Error('age must be a whole number');

If typeof age == 'number' is false Math.trunc(age) == age is never executed because of shortcut And operator &&. But Stryker creates a mutant which assumes that Math.trunc(age) == age must be executed when typeof age == 'number' is false and some test cases must fail.

Is this situation normal? What should I do in this situation? Should I ignore the mutant?

Thanks.

Akif
  • 7,098
  • 7
  • 27
  • 53

0 Answers0