簡體   English   中英

Maven 沒有運行 JUnit 測試

[英]Maven not running JUnit test

我的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 不運行我的單元測試,我該如何解決?

如果您使用的是 JUnit 5 (Jupiter),則需要導入org.junit.jupiter.api.Test而不是org.junit.Test (后者用於 JUnit 4)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM