Skip to content

sualeh/introduction-to-mutation-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐ Star it ⤴️ if you love it!

Introduction to Mutation Testing

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, while C# developers would use NUnit. 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. Examples of such tools are PIT for Java and Stryker for C#.

This tutorial explores how mutation testing works. We will do test-driven development of a simple palindrome function, and follow it through code coverage and mutation testing. A Java project with Apache Maven is provided with instructions for Java developers, and a C# solution too. Start by reading the brief overview of mutation testing included in this tutorial. Read the README file in the corresponding Java or C# for instructions at each step.

Expected time to complete tutorial: 30 minutes

Step 1

In Step 1 we will write unit tests. Please refer to the README files in the C# or the Java folders.