Link

Mutation Testing (PIT)

Table of contents

  1. Mutation Testing (PIT)
  2. Recommended reading

Mutation Testing (PIT)

Mutation testing is used to design new software tests and evaluate the quality of existing software tests. PITest is a mutation testing system, providing great test coverage for Java and the JVM. ThoughtWorks has moved PITest in the access group in the technology radar in November 2016 where it is still today.

PITest requires some Gradle configuration

  1. Plugin

     plugins {
       id 'info.solidsoft.pitest' version '1.5.1'
     }
    
  2. JUnit 5 runtime dependency

     dependencies {
       testRuntimeOnly 'org.pitest:pitest-junit5-plugin:0.12'
     }
    
  3. Configuring PITest

     pitest {
       testPlugin = 'junit5'
       targetClasses = ['demo.*']
       timestampedReports = false
     }
    

No further changes are required to the code. Run the pitest task

$ ./gradlew clean pitest

The clean task is not necessary, but it is useful in cleaning the reports from the previous run.

PITest produces a report at build/reports/pitest/index.html

Pit Test Coverage Report

  1. Chapter 8 Test Adequacy Assessment using Program Mutation of Foundations of Software Testing, 2nd Edition (O’Reilly Books)