错误"ID为'junit-vintage'的TestEngine无法发现测试".使用Spring Boot 2.2 [英] Error "TestEngine with ID 'junit-vintage' failed to discover tests" with Spring Boot 2.2

查看:1328
本文介绍了错误"ID为'junit-vintage'的TestEngine无法发现测试".使用Spring Boot 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Spring Boot和Junit 5的简单应用程序:

I have a simple app using Spring Boot and Junit 5:

  • 使用Spring Boot 2.1(例如2.1.8或2.1.12)时,我的单元测试会运行

  • When using Spring Boot 2.1 (e.g, 2.1.8 or 2.1.12), my unit tests run smoothly

在使用Spring Boot 2.2(例如2.2.2.RELEASE或2.3.2.RELEASE)时,我的单元测试失败并显示错误消息

When using Spring Boot 2.2 (e.g., 2.2.2.RELEASE or 2.3.2.RELEASE) my unit tests fail with error message

[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的任何回归.

I am using Maven 3.6.1, JDK 1.8, JUnit 5.6.0 and JUnit platform 1.6.0. I exclude the dependency on junit:junit from spring-boot-starter-test, so that I have no JUnit 4 artifacts left in the dependency tree. Note that both Spring Boot 2.2 and 2.3 use maven-surefire-plugin 2.22.2, so my problem does not originate from any regression of the maven-surefire-plugin.

为了让我的单元测试正常工作,我应该坚持使用Spring Boot 2.1 吗?

Should I stick to Spring Boot 2.1 in order to have my unit test working?

预先感谢您的帮助.

推荐答案

我发现了错误.对spring-boot-starter-test的依赖性带来对junit-vintage-engine的依赖性.后者必须排除在外:

I found the error. The dependency on spring-boot-starter-test brings a dependency on junit-vintage-engine. The latter must be excluded:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>

这篇关于错误"ID为'junit-vintage'的TestEngine无法发现测试".使用Spring Boot 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆