M Oosterveld
M Oosterveld

Reputation: 26

Surefire throws SurefireReflectionException while class is on classpath

I'm trying to run unit tests generated by evosuite but the maven-surefire-plugin is throwing a classnotfound error while the "missing" class appears to be in the classpath.

When I try to run the tests the debug log shows that evosuite is on the classpath at the time surefire is trying to run the tests;

[DEBUG] test(compact) classpath:  test-classes  classes  junit-4.12.jar  hamcrest-core-1.3.jar  evosuite-standalone-runtime-1.0.6.jar
[DEBUG] provider(compact) classpath:  surefire-junit4-2.17.jar  surefire-api-2.17.jar

But it's failing;

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project Tutorial_Maven: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org.evosuite.runtime.thread.KillSwitch

I double checked if the Killswitch class is in the evosuite jar file and it appears it is.

For completeness, here's the output of mvn -version;

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00)
Maven home: /home/marijn/git/Tutorial_Maven/EMBEDDED
Java version: 1.8.0_252, vendor: Eclipse OpenJ9
Java home: /home/marijn/.sdkman/candidates/java/8.0.252.j9-adpt/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.6.11-100.fc30.x86_64", arch: "amd64", family: "unix"

And the full command I'm running (after following the guide @ https://www.evosuite.org/documentation/tutorial-part-2/ ) is mvn clean compile test-compile evosuite:generate evosuite:export evosuite:prepare test With evosuite parameters memoryInMB = 4000 and cores = 4.

Upvotes: 0

Views: 255

Answers (1)

Keith W. Campbell
Keith W. Campbell

Reputation: 151

I hadn't used EvoSuite before, but I had no trouble with the tutorials using

$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
Eclipse OpenJ9 VM (build openj9-0.21.0, JRE 1.8.0 Linux amd64-64-Bit Compressed > References 20200728_727 (JIT enabled, AOT enabled)
OpenJ9   - 34cf4c075
OMR      - 113e54219
JCL      - c82ff0c20f based on jdk8u265-b01)

My only theory is that perhaps you didn't clear the CLASSPATH environment variable from the first part of the tutorial?

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Executing org.evosuite.runtime.InitializingListener
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Running tutorial.LinkedListIterator_ESTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.558 sec - in tutorial.LinkedListIterator_ESTest
Running tutorial.Node_ESTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec - in tutorial.Node_ESTest
Running tutorial.StackTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in tutorial.StackTest
Running tutorial.LinkedList_ESTest
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.127 sec - in tutorial.LinkedList_ESTest
Running tutorial.Stack_ESTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.101 sec - in tutorial.Stack_ESTest

Results :

Tests run: 28, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:15 min
[INFO] Finished at: 2020-10-29T15:07:28-04:00
[INFO] ------------------------------------------------------------------------

Upvotes: 0

Related Questions