我正在用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