[英]IntelliJ Process finished with exit code 0 when spring-boot run
[英]Junit 5.5.1 and 5.5.2 suddenly failing to run tests: "Process finished with exit code -1"; 5.6.0-RC1 is missing a class
我將 Junit 5.5.1 添加到一個使用 4.11 的項目中。 我編寫的測試直到今天都運行良好。 今天,即使在執行任何測試類之前,所有測試都以退出代碼 -1 失敗。 我不知道會導致此問題的任何依賴項更改。
我切換到 5.6.0-RC1,它似乎缺少一個擴展類 (TestInstancePreDestroyCallback)。
然后我嘗試注意到 5.5.2 並切換到它:它與 5.5.1 有相同的問題。
我又試了一次 5.6.0-RC1 - 這次我注意到 jar 被命名為 5.6.0-M1。 這個版本有效,所以我似乎沒問題,但這是一系列令人不安且缺乏信心的事件。
我的問題是:這是否發生在其他人身上,究竟是什么?
更新:原來 5.6.0-M1 中缺少的類存在於 5.6.0-RC1 中,所以我已經切換到它了。 我不再追求 5.5.* 問題。
就我而言,我收到此錯誤是因為我已將兩者都包含在我的 Spring Boot 應用程序中
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
和
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
我刪除了后者,對我來說效果很好。
我正在為這個問題拉我的頭發。 起初,我錯過了這個依賴
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
但即使我有所有正確的依賴項,它也沒有解決這個錯誤。 最后,我決定在 intelliJ 中使緩存無效並重新啟動(文件 -> 使緩存無效/重新啟動)並且它起作用了。 不知道到底發生了什么,但這是我的解決方案。
最后,這是我的 JUnit/Mockito 依賴項:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
在我的情況下,它是木星依賴。
你應該有:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
或者:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.