Pitest with simple Groovy project
See original GitHub issueHi:
First of all, great work, this project is amazing!
I’m trying to use pitest
in a Groovy
(Gradle
based) project but although it always seems to find Spock
specifications it never creates any mutation. I’ve created a basic Groovy
project (which I’ve attached to this issue pitestgroovyproject.zip) to reproduce the problem.
This is the pitest
configuration
pitest {
targetTests = ['myproject.*']
targetClasses = ['myproject.*']
threads = 4
outputFormats = ['html']
}
The console output:
clean
:compileJava UP-TO-DATE
:compileGroovy
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:pitest
12:10:49 PM PIT >> FINE : Running report with ReportOptions [targetClasses=[^myproject\..*$], excludedMethods=[], excludedClasses=[], codePaths=[/home/dev/ws/build/classes/main], reportDir=/home/dev/ws/build/reports/pitest, historyInputLocation=null, historyOutputLocation=n
ull, sourceDirs=[/home/dev/ws/src/main/resources, /home/dev/ws/src/main/java, /home/dev/ws/src/main/groovy], classPathElements=[/home/dev/.gradle/caches/modules-2/files-2.1/org.pitest/pitest/1.1.9/b9dcaaf81257e9f436c73e59579461d8405e34e5/pitest-1.1.9.jar, /home/dev/ws/build
/classes/test, /home/dev/ws/build/resources/test, /home/dev/ws/build/classes/main, /home/dev/ws/build/resources/main, /home/dev/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.6/478feadca929a946b2f1fb962bb2179264759821/groovy-all-2.4.6.jar, /home/dev/.
gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/1.0-groovy-2.4/ceaa8b69f274ed3de24da3e6a6c86f673b426d1a/spock-core-1.0-groovy-2.4.jar, /home/dev/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar, /hom
e/dev/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar], mutators=[], dependencyAnalysisMaxDistance=-1, mutateStaticInitializers=false, jvmArgs=[], numberOfThreads=4, timeoutFactor=1.25, timeout
Constant=4000, targetTests=[^myproject\..*$], loggingClasses=[], maxMutationsPerClass=0, verbose=true, failWhenNoMutations=true, outputs=[html], groupConfig=TestGroupConfig [excludedGroups=[], includedGroups=[]], mutationUnitSize=0, shouldCreateTimestampedReports=true, dete
ctInlinedCode=false, exportLineCoverage=false, mutationThreshold=0, coverageThreshold=0, mutationEngine=gregor, javaExecutable=null, includeLaunchClasspath=false]
12:10:49 PM PIT >> FINE : System class path is /home/dev/.gradle/caches/modules-2/files-2.1/org.pitest/pitest-command-line/1.1.9/ed8bd8e7802ac2d037cc795f205207915fd8c777/pitest-command-line-1.1.9.jar:/home/dev/.gradle/caches/modules-2/files-2.1/org.pitest/pitest/1.1.9/b9dca
af81257e9f436c73e59579461d8405e34e5/pitest-1.1.9.jar:/home/dev/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar:/home/dev/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f7
1acb49bf010a0/hamcrest-core-1.3.jar
12:10:49 PM PIT >> FINE : Maximum available memory is 2604 mb
12:10:49 PM PIT >> FINE : MINION : Installing PIT agent
12:10:49 PM PIT >> INFO : Sending 1 test classes to minion
12:10:49 PM PIT >> INFO : Sent tests to minion
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> INFO : Checking environment
12:10:49 PM PIT >> FINE : Expecting 1 tests classes from parent
12:10:49 PM PIT >> FINE : Tests classes received
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> INFO : Found 1 tests
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> INFO : Dependency analysis reduced number of potential tests by 0
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> INFO : 1 tests received
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> FINE : Running 1 units
12:10:49 PM PIT >> INFO : MINION : 12:10:49 PM PIT >> FINE : Gathering coverage for test Description [testClass=myproject.LibraryTest, name=myproject.LibraryTest]
12:10:49 PM PIT >> FINE : Coverage generator Minion exited ok
12:10:49 PM PIT >> INFO : Calculated coverage in 0 seconds.
12:10:49 PM PIT >> FINE : Used memory after coverage calculation 19 mb
12:10:49 PM PIT >> FINE : Free Memory after coverage calculation 157 mb
12:10:49 PM PIT >> INFO : Created 0 mutation test units
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:272)
at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:136)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:103)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:45)
at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:76)
at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
:pitest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pitest'.
> Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Thanks Mario
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top Results From Across the Web
FAQ - PIT Mutation Testing
FAQ. What does PIT stand for? PIT began life as a spike to run JUnit tests in parallel, using separate classloaders to isolate...
Read more >Mutation Testing with PITest and Spock 2 - Medium
Gradle building tool; Spock test framework; PITest mutation library ... Gradle and create our basic project from scratch by using SDKMAN!:
Read more >gradle-pitest-plugin: Gradle plugin for PIT Mutation Testing
The configuration in Gradle is the real Groovy code which makes all assignments very intuitive. All values expected by PIT should be passed...
Read more >Mutation Testing with PITest - Baeldung
This article briefly introduces mutation testing using the PITest library. ... we're going to base this demonstration on a basic palindrome ...
Read more >Testing your Java with Groovy, Spock, JUnit5, Jacoco, Jqwik ...
This blog post covers a common scenario seen in the Groovy community which is projects which use Java for their production code and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found that if I ran mvn compile org.pitest:pitest-maven:mutationCoverage to ensure that the groovy files were converted to Java first, then it worked ok.
@jasontrublu Mutating Java code by Groovy/Spock tests should work (at least in a Gradle-based project). The original issue is about mutating Groovy production code. Please raise a separate issue in gradle-pitest-plugin providing link to your project or SSCCE.