[英]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.