我的 pom.xml
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
但是當我這樣做時 mvn clean test
-------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
請注意,IntelliJ 確實識別測驗
(盡管當我單擊test檔案夾并選擇時Run All Tests,它說No tests found)
為什么 Maven 不運行我的單元測驗,我該如何解決?
uj5u.com熱心網友回復:
如果您使用的是 JUnit 5 (Jupiter),則需要匯入org.junit.jupiter.api.Test而不是org.junit.Test(后者用于 JUnit 4)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/345465.html
標籤:爪哇 行家 朱尼特 maven-surefire-plugin
