'Pitest is failing showing: No mutations found due to the supplied classpath or filters + Gradle

I'm trying to run a pitest report on a gradle + kotlin project, but I get the following error:

Exception in thread "main" org.pitest.help.PitHelpError: No mutations found. This probably means there is an issue with either the supplied classpath or filters. See http://pitest.org for more details. at org.pitest.mutationtest.tooling.MutationCoverage.checkMutationsFound(MutationCoverage.java:352) at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:132) at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:123) at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:54) at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:98) at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)

I tried everything that I found on google but still not working for me: This is my build.gradle config

plugins {
id 'groovy-gradle-plugin'
id 'info.solidsoft.pitest' version '1.7.4'
}

repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}


dependencies {
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
implementation 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
}


pitest {
targetClasses = ['com.project.root.to.test.with.pitest.src*']  //by default 
"${project.group}.*"
pitestVersion = '1.7.4' //not needed when a default PIT version should be used
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
}

I tried this targetClasses in a different ways:

targetClasses = ['com.project.root.to.test.with.pitest.src.*']  //by default 
targetClasses = ['com/project/root/to/test/with/pitest/src*']  //by default 

Can someone help me, please?



Solution 1:[1]

You look to be trying to supply pitest with a source folder

com.project.root.to.test.with.pitest.src.

Pitest works against the compiled bytecode, not the source files. It expects a glob that matches against the package.

com.example.*

Solution 2:[2]

I've experienced this same issue today. You'll need to make sure all references to pitest use the same version 1.7.4. This includes

  • plugin: id 'info.solidsoft.pitest' version '1.7.4'
  • pitestVersion: pitestVersion.set('1.7.4')
  • dependency: testCompile 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4'

Which out changing all references, then it will break.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 henry
Solution 2