I'm trying to get pitest running in this java gradle project but having a VERY difficult time... 😢
I have at least two problems: one about packages and one about Java versions.
1)
The first issue is that my project is set up with a public class not contained within any package. I know it is kind of an antipattern to do this, but for a project with only a single java class and test file it seems unnecessary to have an additional package container.
Anyway, it seems like pitest cannot file the file without it being inside of a package. Any I wrong here? Is there something I can put for the "testClasses" value that it would pick up my Lasagna class?
2)
Ok, so in the code here I have declared the "LP" package for my Lasagna class and updated my build.gradle
with this pitest block:
pitest {
targetClasses = ['LP*'] // by default "${project.group}.*"
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
junit5PluginVersion = '1.2.0'
}
The problem though is when I run gradle pitest
I get an "Unsupported class version" Error...
Task :pitest FAILED 11:17:45 AM PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue. Exception in thread "main" java.lang.IllegalArgumentException: Unsupported class file major version 65 at org.pitest.reloc.asm.ClassReader.(ClassReader.java:199) at org.pitest.reloc.asm.ClassReader.(ClassReader.java:180) at org.pitest.reloc.asm.ClassReader.(ClassReader.java:166) at org.pitest.classinfo.ClassInfoVisitor.getClassInfo(ClassInfoVisitor.java:41) at org.pitest.classinfo.Repository.nameToClassInfo(Repository.java:70) at org.pitest.classinfo.Repository.fetchClass(Repository.java:60) at org.pitest.classinfo.NameToClassInfo.apply(NameToClassInfo.java:17) at org.pitest.classinfo.NameToClassInfo.apply(NameToClassInfo.java:7) at java.base/java.util.function.Function.lambda$andThen$1(Function.java:88) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at org.pitest.classpath.CodeSource.getCode(CodeSource.java:44) at org.pitest.mutationtest.verify.DefaultBuildVerifier.verify(DefaultBuildVerifier.java:32) at org.pitest.mutationtest.tooling.MutationCoverage.verifyBuildSuitableForMutationTesting(MutationCoverage.java:275) at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:118) at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:129) at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:57) at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:98) at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
When I run gradle -v
I get this output:
Gradle 8.3
Build time: 2023-08-17 07:06:47 UTC Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5
Kotlin: 1.9.0 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 21 (Homebrew 21) OS: Mac OS X 12.4 x86_64
When I run java -v
it outputs an error, but I do have jabba
installed and can switch versions if I need to, but I am unsure if it even wants me to switch the version my current shell is using or which version to switch it to...
You are using the default version of pitest used by 1.9.0 of the gradle plugin. This is very old.
Either configure an explicit recent version of pitest
pitest {
pitestVersion = '1.15.0'
...
}
Or upgrade to the recent 1.15.0 release of the gradle plugin which uses pitest 1.15.0 by default.