无法使JUnit4和JUnit5测试一起运行-Maven,Surefire

时间:2019-06-20 13:27:22

标签: maven spring-boot junit junit5 maven-surefire-plugin

更新

这是重复的问题。引用重复的答案是我已经查看过的内容。

对我来说,问题是我正在使用的junit-vintage-engine的{​​{1}}版本5.4.2无效。


当前无法让5.3.2连同maven的 JUnit5 测试一起运行 JUnit4 测试。

Surefire插件:

maven-surefire-plugin

当我添加汇总<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <includes> <include>**/*Test.java</include> <include>**/*Runner.java</include> </includes> </configuration> </plugin> (includes engine / params / api)时:

junit-jupiter

...并运行<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.4.2</version> <scope>test</scope> </dependency> ,JUnit5测试运行,但旧的JUnit4测试不运行。当我删除它时,将运行JUnit4测试。 mvn testjunit提供:

spring-boot-starter-test

我遵循here(JUnit文档)中概述的说明,但是这仅导致运行JUnit5测试。这些说明概述了如何添加老式引擎:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>

任何帮助表示赞赏。

谢谢

0 个答案:

没有答案
相关问题