Summer Sale! All accounts are 50% off this week.

BernardoBF4's avatar

Mutation tests and their value

Recently I have been working with mutation tests just to experiment. They're very cool indeed, but I wonder what is the value they add. I have heard a lot about them improving the quality of your tests by asserting (no pun intended) your tests actually test something useful.

But I really can't see that. I know mutation tests are designed to change certain validation or return values and then check if those changes will be caught, but the thing I don't understand is: why would I test if changing my code validations and return values? Isn't my code supposed to work with the test (normal test) written before; I mean, shouldn't the "normal tests" assure my code works as supposed?

Also, how can one implemente mutation tests in TDD cycles?

0 likes
1 reply
martinbean's avatar

@bernardobf4 I’m in the same boat as you. I had a previous role where a colleague added mutation tests to the project, but never understand the value in them as it’s counter-intuitive to think of a mutation to then test if you code breaks. It doesn’t make sense to me to change code so it fails, and then to test it does indeed fail.

I just cover my apps with feature tests that include cases for validation. I’ll create a “happy path” case, and then cases with intentionally bad input data just to test my validation rules are in place and validation responses are indeed returned.

2 likes

Please or to participate in this conversation.