简体   繁体   中英

pitest not running correctly

I am trying to run pitest on some sourcecode. Now it is complaining that it didn't find any mutations. Using the verbose instruction didn't show any issues for me.

See the following output:

    C:\Users\lukkezenm\workspace\pittest\pittest>gradlew pitest
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:compileImplJava UP-TO-DATE
:processImplResources UP-TO-DATE
:implClasses UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:pitest
12:05:10 PM PIT >> FINE : Running report with ReportOptions [targetClasses=[^myo
rg\..*$], excludedMethods=[], excludedClasses=[], codePaths=[C:\Users\lukkezenm\
workspace\pittest\pittest\build\classes\main], reportDir=C:\Users\lukkezenm\work
space\pittest\pittest\build\reports\pitest, historyInputLocation=null, historyOu
tputLocation=null, sourceDirs=[C:\Users\lukkezenm\workspace\pittest\pittest\src\
main\resources, C:\Users\lukkezenm\workspace\pittest\pittest\src\main\java], cla
ssPathElements=[C:\Users\lukkezenm\.gradle\caches\modules-2\files-2.1\org.pitest
\pitest\1.1.6\3f0653443fe5ec2546c91140d3dcf007cd772dad\pitest-1.1.6.jar, C:\User
s\lukkezenm\workspace\pittest\pittest\build\classes\test, C:\Users\lukkezenm\wor
kspace\pittest\pittest\build\resources\test, C:\Users\lukkezenm\workspace\pittes
t\pittest\build\classes\main, C:\Users\lukkezenm\workspace\pittest\pittest\build
\resources\main, C:\Users\lukkezenm\workspace\pittest\pittest\build\classes\api,
 C:\Users\lukkezenm\workspace\pittest\pittest\build\resources\api, C:\Users\lukk
ezenm\workspace\pittest\pittest\build\classes\impl, C:\Users\lukkezenm\workspace
\pittest\pittest\build\resources\impl, C:\Users\lukkezenm\.gradle\caches\modules
-2\files-2.1\commons-codec\commons-codec\1.5\cf993e250ff71804754ec2734a16f23c0be
99f70\commons-codec-1.5.jar, C:\Users\lukkezenm\.gradle\caches\modules-2\files-2
.1\commons-lang\commons-lang\2.6\ce1edb914c94ebc388f086c6827e8bdeec71ac2\commons
-lang-2.6.jar, C:\Users\lukkezenm\.gradle\caches\modules-2\files-2.1\junit\junit
\4.9\1013627e3993319870863a020034004717505815\junit-4.9.jar, C:\Users\lukkezenm\
.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.1\86034056225067
8d1a344907ac75754e259cdb14\hamcrest-core-1.1.jar], mutators=[], dependencyAnalys
isMaxDistance=-1, mutateStaticInitializers=false, jvmArgs=[], numberOfThreads=1,
 timeoutFactor=1.25, timeoutConstant=4000, targetTests=[], loggingClasses=[], ma
xMutationsPerClass=0, verbose=true, failWhenNoMutations=true, outputs=[HTML], gr
oupConfig=TestGroupConfig [excludedGroups=[], in                               c
ludedGroups=[]], mutationUnitSize=0, shouldCreateTimestampedReports=true, detect
InlinedCode=false, exportLineCoverage=false, mutationThreshold=0, coverageThresh
old=0, mutationEngine=gregor, javaExecutable=null, includeLaunchClasspath=false]

12:05:10 PM PIT >> FINE : System class path is C:\Users\lukkezenm\.gradle\caches
\modules-2\files-2.1\org.pitest\pitest-command-line\1.1.6\4abe3b86a567be1be40f15
82b6a56fdc333a574a\pitest-command-line-1.1.6.jar;C:\Users\lukkezenm\.gradle\cach
es\modules-2\files-2.1\org.pitest\pitest\1.1.6\3f0653443fe5ec2546c91140d3dcf007c
d772dad\pitest-1.1.6.jar;C:\Users\lukkezenm\.gradle\caches\modules-2\files-2.1\j
unit\junit\4.11\4e031bb61df09069aeb2bffb4019e7a5034a4ee0\junit-4.11.jar;C:\Users
\lukkezenm\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a
25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar
12:05:10 PM PIT >> FINE : Maximum available memory is 247 mb
12:05:10 PM PIT >> FINE : using port 8092
12:05:10 PM PIT >> INFO : Sending 0 test classes to slave
12:05:10 PM PIT >> INFO : Sent tests to slave
12:05:10 PM PIT >> FINE : Coverage generator Slave exited ok
12:05:10 PM PIT >> INFO : Calculated coverage in 0 seconds.
12:05:10 PM PIT >> FINE : Used memory after coverage calculation 3 mb
12:05:10 PM PIT >> FINE : Free Memory after coverage calculation 11 mb
12:05:10 PM PIT >> INFO : Created  0 mutation test units
Exception in thread "main" org.pitest.help.PitHelpError: No mutations found. Thi
s 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:271)
        at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCo
verage.java:138)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:10
5)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:46
)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(
MutationCoverageReport.java:74)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.main(Mutat
ionCoverageReport.java:45)
:pitest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pitest'.
> Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_79\bin\java.exe'' finis
hed with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.542 secs

C:\Users\lukkezenm\workspace\pittest\pittest>

My build.gradle file:

apply plugin: "java"
apply plugin: "maven"
apply plugin: "info.solidsoft.pitest"

group = "myorg"
version = 1.0

repositories {
    mavenCentral()
}

sourceSets.all { set ->
    def jarTask = task("${set.name}Jar", type: Jar) {
        baseName = baseName + "-$set.name"
        from set.output
    }

    artifacts {
        archives jarTask
    }
}

sourceSets {
    api
    impl
}

buildscript {
    repositories {
        mavenCentral()
        //Needed only for SNAPSHOT versions
        //maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
    }
    dependencies {
        classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.6'
    }
}

dependencies {
    apiCompile 'commons-codec:commons-codec:1.5'

    implCompile sourceSets.api.output
    implCompile 'commons-lang:commons-lang:2.6'

    testCompile 'junit:junit:4.9'
    testCompile sourceSets.api.output
    testCompile sourceSets.impl.output
    runtime configurations.apiRuntime
    runtime configurations.implRuntime
}

jar {
    from sourceSets.api.output
    from sourceSets.impl.output
}

pitest
{
verbose="on"
}

Adding the following in the build.gradle file solved the issue:

pitest
{
println sourceSets.main
    targetClasses = ['d*']  //by default "${project.group}.*"
    targetTests  = ['*Test*']
}

I just spent a great deal of time with the same message

No mutations found. This probably means there is an issue with either the supplied classpath or filters.

My problem was simple: I had created a couple of test projects in IntelliJ using Maven. But I did not have a package. I was using the default package and PITest was failing every time. The PITest has a plugin that might work with just the default package if you specify the class and test classes. But all the documentation said that it should work by default. A verbose output even showed that PITest was finding the correct project folders, but it still didn't work. Henry Cole was even good enough (the developer of PITest) to look at my POM.xml file and confirm that it looked good.

In summary, PITest works great if you put your Java code in a package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM