0

我正在尝试运行由 evosuite 生成的单元测试,但是 maven-surefire-plugin 抛出了一个 classnotfound 错误,而“缺失”类似乎在类路径中。

当我尝试运行测试时,调试日志显示在surefire 尝试运行测试时evosuite 位于类路径上;

[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

但它失败了;

[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

我仔细检查了 Killswitch 类是否在 evosuite jar 文件中,并且看起来确实如此。

为了完整起见,这里是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"

我正在运行的完整命令(在遵循指南@ https://www.evosuite.org/documentation/tutorial-part-2/之后)是mvn clean compile test-compile evosuite:generate evosuite:export evosuite:prepare test使用 evosuite 参数 memoryInMB = 4000 和 cores = 4。

4

1 回答 1

0

我以前没有使用过 EvoSuite,但是使用教程我没有遇到任何问题

$ 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)

我唯一的理论是,也许您没有CLASSPATH从教程的第一部分清除环境变量?

-------------------------------------------------------
 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] ------------------------------------------------------------------------
于 2020-10-29T19:11:38.503 回答