test命令不能触发Junit5测试用例

test命令不能触发Junit5测试用例

maven不能触发Junit5测试用例

使用 MAVEN PACKAGE打包时,JUnit4可以在打包时运行全部测试用例,而JUnit5不会运行。这是因为现在 maven 并不能直接识别JUnit5测试用例,需要在插件中添加 maven surefire。

1
2
3
4
5
6
7
8
9
<build>
<plugins>
<!--fix: mvn test not run junit5 @Test -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

再次运行 mvn clean pacakge 即可触发TestCase。

gradle不能触发Junit5测试用例

在项目下使用./graldew test,不能触发Junit5的测试用例,但是Junit4是可以的。

1
2
3
4
5
buildscript {
dependencies {
classpath ("org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4")
}
}