maven surefire插件没有查找单位测试
- 是的,包含测试的Java类是正确命名的。 (他们以测试结尾)
- 试图在pom.xml中添加以下配置:
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
- 测试位于以下结构下:/src/test/test/packagename/javaclasstest.java,其中 packagename 是同一包在SRC/MAIN/JAVA路径下编写的单位测试下的包装。
- 我使用的是Jupiter Junit 5和2.22.2的Maven-Surefire-Plugin
,并且在MVN测试中仍然会遇到以下错误:
--- maven-surefire-plugin:2.22.2:test (default-test) @ <project-name> ---
[INFO] No tests to run.
我做错了什么?
- Yes, the Java classes which are containing the tests are named correctly. (they are ending with Tests)
- Tried to add the following configuration in pom.xml:
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
- Tests are located under the following structure: /src/test/packagename/JavaClassTest.java where packagename is the same package what is under the unit test written under src/main/java path.
- I'm using jupiter Junit 5 and maven-surefire-plugin with 2.22.2
And I still get the following error on mvn test:
--- maven-surefire-plugin:2.22.2:test (default-test) @ <project-name> ---
[INFO] No tests to run.
What do I do wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有什么原因是您仅配置某个测试?默认情况下,SureFire插件应访问TestRoot和子目录中的所有类。
之类的特定文件链接起来,
您还可以将诸如src/test/archtest.java
以查看它是在您的配置中或其他内容中的“ Include”。我不确定野生硬病能是否正如您期望的那样工作。参见 maven> maven&lt;部分文件夹名称上的通配符匹配。
基于此,您可能会尝试
Is there any reason why you configure just a certain tests? By default the surefire plugin should access all classes in testRoot and sub directories.
You could also just link a specific file like
src/test/ArchTest.java
to see if it is the "include" in your configuration or something else. I am not sure that the wildecards are working as you expect them to work. See Maven <include> wildcard match on partial folder name .
Based on this you might try out
将其添加到Junit 5
添加此junit 4
add this for junit 5
add this for junit 4