我有一个使用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吗?