【发布时间】:2017-05-05 05:32:06
【问题描述】:
Maven 执行
mvn clean test
我正在尝试将 junit5 用于我的一个 maven 项目,但无法在 test 阶段使用 - 执行单元测试 -
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
</dependency>
我得到的输出是 -
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ utils --- ------------------------------------------------------- T E S T S ------------------------------------------------------- Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
尝试实现@Surefire is not picking up Junit 5 tests 提到的解决方案以将依赖项更新为 -
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-api</artifactId>
<version>5.0.0-ALPHA</version><!--https://mvnrepository.com/artifact/org.junit/junit5-api -->
<scope>test</scope>
</dependency>
并将插件更新为 -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>surefire-junit5</artifactId>
<version>5.0.0-ALPHA</version><!--couldn't find this on the central though-->
</dependency>
</dependencies>
</plugin>
但输出保持不变。
问题 - 目前是否不再支持此自定义提供程序,或者是否有任何解决方案可以使用 maven、junit5 和/或 junit5-api 执行测试?
注意 - 测试执行在 JUnit-4 上运行良好。
【问题讨论】:
-
您的项目结构如何?您的单元测试在哪个目录中?
-
它们位于相应的
src/test文件夹本身中。事实上,使用 intelliJ 的快捷方式生成单元测试。会更新junit4
标签: java maven unit-testing junit5