DEV Community

Around IT In 256 Seconds

#15: Mutation testing

Imagine I wrote a script that takes your codebase and removes a random line. Fairly simple. Or maybe some more subtle change, like replacing plus with minus operator? Or switching `x` and `y` parameters with each other? OK, so now my script builds your project. Most of the time it will fail the compilation or test phase. But what if the build succeeds?

Well, apparently your test suite is not covering some lines? OK, but what if my script only removes or alters lines covered by tests? How is it possible that the build still succeeds? Turns out your tests aren't as good as you think. And I just described mutation testing that discovers that.

Read more: https://256.nurkiewicz.com/15

Get the new episode straight to your mailbox: https://256.nurkiewicz.com/newsletter

Episode source