Maven执行
mvn clean test我试图在我的maven项目中使用junit5,但无法在test阶段使用-
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
</dependency>我得到的输出是-
信息-- maven-surefire-plugin:2.19.1:test (默认-test)@ utils -E、S-S失败: 0,错误: 0,跳过: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来执行测试?
Note -测试执行在JUnit-4中运行良好。
发布于 2016-12-20 07:11:40
您应该像这样配置maven-surefire-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M3</version>
</dependency>
</dependencies>
</plugin>您只需要在依赖项部分的测试范围中包含junit-jupiter工件:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M3</version>
<scope>test</scope>
</dependency>有关更多信息,请参见http://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven。
编辑-来自相同的文档。
为了让Maven完全运行任何测试,必须将
TestEngine实现添加到运行时类路径中。
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M3</version>
</dependency>
</dependencies>
</plugin>https://stackoverflow.com/questions/41234886
复制相似问题