[英]IntelliJ can't find tests if package name exists in src/main/java
I'm trying to introduce Unit tests to our system, and have run into a problem with Junit not finding test.我正在尝试向我们的系统引入单元测试,但遇到了 Junit 找不到测试的问题。 I have these 3 tests:
我有这3个测试:
When I run all tests in the module:当我运行模块中的所有测试时:
It finds X and Y tests, but not Z:它找到 X 和 Y 测试,但没有找到 Z:
The difference between the 3 is only in the package name: 3者的区别仅在于package名称:
com.exlibris.x
(XTest) doesn't exist in the projectcom.exlibris.x
(XTest)com.exlibris.core.infra.svc.api.flags
(YTest) exists in a different module in the project (that is outputted to a different jar file) com.exlibris.core.infra.svc.api.flags
(YTest) 存在于项目的不同模块中(输出到不同的 jar 文件)com.exlibris.repository.web.mms.publishing
(ZTest) exists in the same module under the src/main/java com.exlibris.repository.web.mms.publishing
(ZTest)存在于src/main/java下的同一模块中My pom.xml has the following dependencies (inherited from the parent pom):我的 pom.xml 具有以下依赖项(继承自父 pom):
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
EDIT: These are my run configurations编辑:这些是我的运行配置
So it turned out there were a few issues (some of them are likely not related to the specific question, but still best practices).所以事实证明存在一些问题(其中一些可能与特定问题无关,但仍然是最佳实践)。 What helped for me was:
对我有帮助的是:
Thanks a lot to khmarbaise and Kathrin Geilmann for the help:)非常感谢khmarbaise和Kathrin Geilmann的帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.