maven版本:3.6.3
surefire-plugin版本:2.12
Junit5
在终端执行mvn -Dtest=TestClass test,显示No tests were executed!,Tests run:0

检查导入的包没有问题,单独运行测试类可正常执行测试用例。
尝试办法1:在-Dtest中加上文件所在位置包名(mvn -Dtest=com.xxx.TestClass test);未解决
尝试办法2:尝试重新加载依赖;未解决
尝试办法3:执行mvn clean,之后再执行test;未解决
搜索之后,发现有文章提到“The Maven Surefire Plugin 2.22.0 (or newer) provides native support for JUnit 5”
尝试办法4:修改surefire-plugin版本为2.22.2;未解决
尝试办法5:Why Your JUnit 5 Tests Are Not Running Under Maven; junit-platform-surefire-provider是通过surefire运行junit5很重要的依赖jar&#x
在使用Maven 3.6.3和Surefire-plugin 2.12时,执行`mvn -Dtest=TestClass test`遇到'No tests were executed!'错误。尽管测试类能单独运行,但通过Maven运行则不成功。尝试更新Surefire-plugin到2.22.2,添加junit-platform-surefire-provider依赖等方法后,最终通过修改pom.xml使测试用例正常执行。
最低0.47元/天 解锁文章
2795

被折叠的 条评论
为什么被折叠?



