⭐ Star it
⤴️ if you love it!
Watch a video of this tutorial on YouTube.
Most developers are familiar with the concept of unit testing, and how this is useful to ensure validity of your code, and guard against bugs creeping up in the future. Java developers will typically use JUnit to write their unit tests. Many projects use test coverage tools such as Jacoco to ensure that the code as written has tests to validate it. But how strong are the tests? Will they stand up against bugs introduced by future code changes?
Mutation testing helps ensure that that tests themselves are of high quality by introducing random bugs, or mutations, and checking if any of unit tests can catch the bug. While this concept has been around for a while, it is just recently that good tools are becoming available for this purpose. One such tool is PIT.
This tutorial explores how mutation testing works. We will do test-driven development of a simple palindrome function, and follow it through code coverage with Jacoco and mutation testing with PIT. Start by reading the brief overview of mutation testing included in this tutorial. Read the README file for instructions at each step.
Expected time to complete tutorial: 30 minutes
Follow along this tutorial. You will need to have at least Java 8 installed, and Apache Maven on the PATH. Clone this repository, and fire up an IDE such as IntelliJ IDEA to follow along.
In order to move to Step 1, switch to git branch "step1" by running git switch step1
. Then follow instructions in the README.