我正在用maven,scala和junit編寫一個簡單的項目。Maven項目找不到junit
我發現的一個問題是我的測試找不到org.junit.framework.Test。測試文件:
import org.junit.framework.Test
class AppTest {
@Test
def testOK() = assertTrue(true)
@Test
def testKO() = assertTrue(false)
}
返回錯誤:
[WARNING]..... error: object junit is not a member of package org
[WARNING] import org.junit.framework.Test
[WARNING] ^
我確實有增加的JUnit作爲一個依賴,它清楚地坐在我的倉庫裏。
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
有人可以告訴我是什麼原因造成的嗎?
非常感謝
測試文件是否在測試文件夾中?如果不是的話,測試的範圍將會搞砸一切。嘗試刪除範圍標籤,看看是否有幫助。 POM中的其餘依賴關係在這裏看起來很好。其次,你的AppTest類是什麼包? – 2012-02-28 18:39:22
感謝您的回覆。是的,測試代碼位於測試文件夾中。該文件位於包com.mycompany.myservice中。 – Kevin 2012-02-28 19:16:15
你的.m2文件夾中是否有junit .jars文件?我認爲這是〜/ .m2 /默認存儲庫。 – 2012-02-28 21:04:00