我在没有JUnit
的maven项目中使用maven-surefire-plugin
3和4已经很长时间了。
目前,我开始尝试JUnit 5,使用来自JUnit木星包org.junit.jupiter.api
的注释。特别是使用org.junit.jupiter.api.Test
代替了遗留的org.junit.Test
。最终,没有检测到任何测试,因此测试失败。
maven-surefire-plugin
必须以这样的方式添加到pom.xml
中:`
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
在此,我想问:
maven-surefire-plugin
必须与JUnit5一起使用,而不是JUnit4或JUnit3?使代码尽可能简单是我的习惯。
发布于 2017-08-11 09:39:31
maven-surefire-plugin中的Junit5支持尚未完成,需要一个新版本的maven-surefire-plugin,即目前正在研究。
https://stackoverflow.com/questions/45629573
复制相似问题