[英]IntelliJ can't find tests if package name exists in src/main/java
我正在尝试向我们的系统引入单元测试,但遇到了 Junit 找不到测试的问题。 我有这3个测试:
当我运行模块中的所有测试时:
它找到 X 和 Y 测试,但没有找到 Z:
3者的区别仅在于package名称:
com.exlibris.x
(XTest)com.exlibris.core.infra.svc.api.flags
(YTest) 存在于项目的不同模块中(输出到不同的 jar 文件)com.exlibris.repository.web.mms.publishing
(ZTest)存在于src/main/java下的同一模块中我的 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>
编辑:这些是我的运行配置
所以事实证明存在一些问题(其中一些可能与特定问题无关,但仍然是最佳实践)。 对我有帮助的是:
非常感谢khmarbaise和Kathrin Geilmann的帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.