2017-07-18 44 views
0

我正在使用Junit在Netbeans的Maven項目中測試一些代碼。指定的依賴項是Junit 4.12(在pom.xml中)。import junit jupiter api not found

但是,我得到一個編譯器錯誤,當我嘗試建立:

error: package org.junit.jupiter.api does not exist

在這條線: import org.junit.jupiter.api.Test;

我懷疑這是一個Junit4/Junit5的事情,因爲當我在IntelliJ中打開該項目的舊版本,它將Junit5列爲依賴項。我應該只使用Junit5嗎?

任何幫助解決構建錯誤,將不勝感激!

回答

0

你需要注入前開始寫測試jupiter假象

Group ID: org.junit.jupiter 
Artifact ID: junit-jupiter-api 
Version: 5.0.0-M5 

JUnit JupiterJUnit 5子模塊,所以你需要使用JUnit 5

<dependency> 
    <groupId>org.junit.jupiter</groupId> 
    <artifactId>junit-jupiter-api</artifactId> 
    <version>5.0.0-M5</version> 
    <scope>test</scope> 
</dependency> 
+0

謝謝,這是我目前有: ' junit junit 4.12 測試 ' –

+0

不過,我仍然得到同樣的錯誤之前 –

+0

請出示你的'pom.xml'文件? – Aryan

相關問題