You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried the use EvoSuite 1.1.1-SNAPSHOT on JDK 11 with Maven on the files from the EvoSuite Maven Tutorial
Test generation is not started because of a ClassNotFoundException for the CUTs of the tutorial
As far as I could debug the problem is that continuous mode (which is called from the EvoSuite Maven plugin) uses ProjectAnalyzer to check classes.
The target parameter is correctly passed to Continuous, it tries to use ClassPathHacker to add files in the target classes to the actual classpath (which is currently EvoSuite's classpath and not the target's), but it failes because in Java 9+ the default classloader is not an URLClassLoader.
Therefore the classpath remains the original one, and ProjectAnalyzer will fail during Class<?> clazz = Class.forName(className);.
Relevant part of the log:
[INFO] [MASTER] 22:59:12.444 [main] ERROR ClassPathHacker - Trying to add URL to class path:file:/C:/code/Tutorial_Maven/target/test-classes/
[INFO] [MASTER] 22:59:12.445 [main] ERROR ClassPathHacker - Did not add file:/C:/code/Tutorial_Maven/target/test-classes/, because system class loader is no URLClassLoader
...
[INFO] [MASTER] 21:52:09.636 [main] ERROR ProjectAnalyzer - java.lang.ClassNotFoundException: tutorial.LinkedList
[INFO] java.lang.ClassNotFoundException: tutorial.LinkedList
[INFO] at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
[INFO] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
[INFO] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
[INFO] at java.base/java.lang.Class.forName0(Native Method)
[INFO] at java.base/java.lang.Class.forName(Class.java:332)
[INFO] at org.evosuite.continuous.project.ProjectAnalyzer.getCutsToAnalyze(ProjectAnalyzer.java:179)
[INFO] at org.evosuite.continuous.project.ProjectAnalyzer.analyze(ProjectAnalyzer.java:210)
[INFO] at org.evosuite.continuous.ContinuousTestGeneration.execute(ContinuousTestGeneration.java:157)
[INFO] at org.evosuite.executionmode.Continuous.execute(Continuous.java:138)
[INFO] at org.evosuite.EvoSuite.parseCommandLine(EvoSuite.java:351)
[INFO] at org.evosuite.EvoSuite.main(EvoSuite.java:115)
(I have added a few log messages during debug to the source, thus some of the line numbers changed.)
If I start the test generation from the CLI without continuous mode, then tests are generated. As far as I can see this is because the other mode (TestGeneration.executeTestGeneration) skips ProjectAnalyzer. It also tries to use ClassPathHacker (which fails also in this mode), but uses ResourceList to get the class. This suceed, because it uses the SUT class loader from TestGenerationContext.
Maybe ProjectAnalyzer could also rely on ResourceList to get the classes and check whether they are tests. (For this, a Class instance is required, but perhaphs the output of getClassAsStream can be converted (like in InstrumentingClassLoader).
Steps to Reproduce
Use openJDK 11 (but I guess it is the same for any 9+ JDK)
Get the source of EvoSuite, build and install it locally with mvn install (as currently 1.1.0 is not yet on Maven Central)
Get the maven tutorial project, add plugin to pom with 1.1.1-SNAPSHOT version
Try to generate tests: mvn evosuite:generate
Test generation will fail for all 4 classes in the tutorial
EvoSuite Arguments
Please provide the whole EvoSuite commmand you executed (if relevant)
Context
ClassNotFoundException
for the CUTs of the tutorialProjectAnalyzer
to check classes.target
parameter is correctly passed toContinuous
, it tries to useClassPathHacker
to add files in the target classes to the actual classpath (which is currently EvoSuite's classpath and not the target's), but it failes because in Java 9+ the default classloader is not anURLClassLoader
.ProjectAnalyzer
will fail duringClass<?> clazz = Class.forName(className);
.Relevant part of the log:
(I have added a few log messages during debug to the source, thus some of the line numbers changed.)
TestGeneration.executeTestGeneration
) skipsProjectAnalyzer
. It also tries to useClassPathHacker
(which fails also in this mode), but usesResourceList
to get the class. This suceed, because it uses the SUT class loader fromTestGenerationContext
.Maybe
ProjectAnalyzer
could also rely onResourceList
to get the classes and check whether they are tests. (For this, a Class instance is required, but perhaphs the output ofgetClassAsStream
can be converted (like inInstrumentingClassLoader
).Steps to Reproduce
mvn install
(as currently 1.1.0 is not yet on Maven Central)mvn evosuite:generate
EvoSuite Arguments
Please provide the whole EvoSuite commmand you executed (if relevant)
mvn evosuite:generate
it translates to:
Current Result
Please describe here below the current result you got (if relevant)
[main] ERROR ProjectAnalyzer - java.lang.ClassNotFoundException: tutorial.LinkedListIterator
Expected result
Please describe here below what should be the expected behaviour (if relevant)
Additional info
Please add any information of interest here below
The text was updated successfully, but these errors were encountered: