EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
824 stars 341 forks source link

Issue with Generating Test Suite using EvoSuite #476

Open yz-qiang opened 2 months ago

yz-qiang commented 2 months ago

Problem Description

Hello,

I am attempting to generate a test suite for my project using EvoSuite. I have downloaded the evosuite-1.2.0.jar and tried to generate the test suite with the following command:

java -jar evosuite-1.2.0.jar -target target/classes -generateTests -projectCP target/classes

However, I encountered an error:


Picked up JAVA_TOOL_OPTIONS: -Duser.language=en -Duser.country=US
* EvoSuite 1.2.0
* Found 938 matching classes in target target/classes
* Analyzing classpath (generating inheritance tree)
  - target/classes
[MASTER] 22:20:27.331 [main] ERROR EvoSuite - Fatal crash on main EvoSuite process. Class  using seed 1718461227327. Configuration id : null
java.lang.IllegalArgumentException: Unsupported class file major version 65
        at org.evosuite.shaded.org.objectweb.asm.ClassReader.<init>(ClassReader.java:199)
        at org.evosuite.shaded.org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
        at org.evosuite.shaded.org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
        at org.evosuite.shaded.org.objectweb.asm.ClassReader.<init>(ClassReader.java:287)
        at org.evosuite.setup.InheritanceTreeGenerator.analyzeClassStream(InheritanceTreeGenerator.java:233)
        at org.evosuite.setup.InheritanceTreeGenerator.createFromClassPath(InheritanceTreeGenerator.java:98)
        at org.evosuite.EvoSuite.generateInheritanceTree(EvoSuite.java:76)
        at org.evosuite.executionmode.TestGeneration.generateTestsTarget(TestGeneration.java:638)
        at org.evosuite.executionmode.TestGeneration.executeTestGeneration(TestGeneration.java:88)
        at org.evosuite.EvoSuite.parseCommandLine(EvoSuite.java:335)
        at org.evosuite.EvoSuite.main(EvoSuite.java:103)

Here is my current java -version:

shell
% java -version
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en -Duser.country=US
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-29)
OpenJDK 64-Bit Server VM (build 21.0.1+12-29, mixed mode, sharing)

Here are the properties in my pom.xml:

xml
<properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Could you please advise on how to resolve this issue? Thank you!

Additionally, I noticed that the EvoSuite homepage states that it supports Java 8 or Java 9. Is it compatible with JDK 17 or JDK 21?

Thank you!