3

I have some trouble understanding how to find a bug using mutants.

So, there is the original code, I make mutants, and check for reachability, infection and propagation, find tests which kill mutants (if they exist), and than what? How should that help me to find a bug in my code?

wdc
  • 2,623
  • 1
  • 28
  • 41

1 Answers1

2

Mutation testing isn't for testing your src code it is for testing your test code.

It's for answering the question,

How do I ensure my (automated) unit test suite is good enough?

If your tests still pass after being mutated it implies they are not covering what they should be or not covering enough.

The java mutation testing framework has a good high level run down of mutation testing on their landing page,

http://pitest.org/

Darren Forsythe
  • 10,712
  • 4
  • 43
  • 54
  • Thanks, I got question on exam to find bug in code using mutation method, so don't actually know what that mean. – wdc Jun 30 '17 at 15:03
  • essentially your tests are not covering, for example, a statement like `if(varA == 1){ do stuff}`. In your tests you would need to be able to change the value of varA and assert responses/interactions within the src code. If they do not the mutation test would still pass, as they could change it to `if(varA != 1){do stuff}`. Tests which pass after mutation testing are fail. – Darren Forsythe Jun 30 '17 at 15:07