java Surefire 2.22.2在删除提供程序依赖项后找不到junit测试
第一次发布!我已经试着浏览了所有其他关于surefire问题的帖子,但没有任何结果,所以如果有任何帮助,我将不胜感激
我目前正在尝试处理项目中的“junit平台surefire提供程序已被弃用”警告。目前正在使用surefire的2.22.2版本,我们的项目中的所有junit jupiter测试都可以在该版本中找到
警告: junit平台surefire提供程序已被弃用,并计划 在JUnit平台1.4中删除。请使用Maven中的内置支持 Surefire>;=而不是2.22.0。 https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven
Test results with 55 tests found
当我试图从插件中删除junit平台surefire提供程序和jupiter引擎依赖项时,问题就出现了
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
这个提供者将被弃用,我正试图摆脱它。为了尝试使用Maven Surefire中的内置支持,我遵循了https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven的文档。除了删除这两个依赖项之外,我还将以下两个依赖项添加到POM文件的部分中
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
完成此操作后,构建将完成,但它不再找到任何测试
Test Results with ZERO tests found
有什么我遗漏的吗
# 1 楼答案
更新
也有同样的问题
添加在pom上。xml
工作正常,运行所有测试
# 2 楼答案
我有一个类似的问题,我需要用Junit 5运行Junit 4.12测试。在添加Junit 5测试后,我遇到了下一个错误:
我读到了
可以解决我的问题,但当我尝试运行测试时,我收到了下一条消息
最后,next pom设置为我修复了它:
现在,当我尝试运行Junit 4.12测试时,它们被找到并执行
更新
我注意到log4j日志有一些问题,它只显示异常堆栈跟踪。Junit5也停止了工作。因此,在对pom文件的最终版本进行了更多测试之后