我正在尝试在某些源代码上运行pitest。现在它抱怨它没有发现任何突变。 使用详细说明并没有给我带来任何问题。
请参阅以下输出:
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>
我的build.gradle文件:
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"
}
答案 0 :(得分:2)
在build.gradle文件中添加以下内容解决了问题:
pitest
{
println sourceSets.main
targetClasses = ['d*'] //by default "${project.group}.*"
targetTests = ['*Test*']
}
答案 1 :(得分:0)
我花了很多时间用同样的信息
未发现任何突变。这可能意味着提供的类路径或过滤器存在问题。
我的问题很简单:我使用Maven在IntelliJ中创建了几个测试项目。但我没有包裹。我使用的是默认包,PITest每次都失败了。如果指定类和测试类,PITest有一个插件可能只使用默认包。但是所有的文档都说它应该默认工作。一个详细的输出甚至表明PITest找到了正确的项目文件夹,但它仍然无法正常工作。 Henry Cole甚至还不错(PITest的开发人员)查看我的POM.xml文件并确认它看起来不错。
总之,如果将Java代码放在一个包中,PITest就会很好用。