【发布时间】:2020-05-11 00:40:57
【问题描述】:
我有一个使用 Spring Boot 和 Junit 5 的简单应用:
当使用 Spring Boot 2.1(例如,2.1.8 或 2.1.12)时,我的单元测试运行 顺利
使用 Spring Boot 2.2(例如 2.2.2.RELEASE 或 2.3.2.RELEASE)时,我的单元测试失败并显示错误消息
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:656)
我正在使用 Maven 3.6.1、JDK 1.8、JUnit 5.6.0 和 JUnit 平台 1.6.0。我从spring-boot-starter-test 中排除了对junit:junit 的依赖,因此我在依赖树中没有JUnit 4 工件。请注意,Spring Boot 2.2 和 2.3 都使用 maven-surefire-plugin 2.22.2,所以我的问题不是源自 maven-surefire-plugin 的任何回归。
我应该坚持使用 Spring Boot 2.1 以使我的单元测试正常工作吗?
提前感谢您的帮助。
【问题讨论】:
-
因为这意味着
mvn使用了错误的 JDK 11,而不是 15
标签: spring-boot junit5