为什么junit测试不能与"sbt测试"一起执行? [英] Why don't junit tests get executed with "sbt test"?
本文介绍了为什么junit测试不能与"sbt测试"一起执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将sbt版本0.13.2与纯Java项目一起使用.
I am using sbt version 0.13.2 with a pure java project.
我的build.sbt
中包含以下行:
libraryDependencies ++= Seq("com.novocode" % "junit-interface" % "0.10" % "test")
我的测试如下:
import org.junit.Test;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.Assert.*;
@RunWith(JUnit4.class)
public class ExampleTest{
@Test
public void firstTest(){
org.junit.Assert.assertEquals("2.5 + 7.5 = 10.0", 2.5 + 7.5, 10.0, .1);
}
}
当我从命令行执行sbt test
时,测试已成功编译,但测试未运行.它说
When I do sbt test
from the command line, the test is successfully compiled, but the test does not run. It says
Compiling 1 Java source to [my path]/target/scala-2.10/test-classes...
...
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 1 s, completed May 31, 2014 5:56:22 PM
有什么想法可以执行测试吗?
Any idea how to get the test executed?
推荐答案
当我删除@RunWith
批注时,我的测试运行得很好.我不知道为什么这可以解决问题.
When I remove the @RunWith
annotation, my tests run just fine. I don't know why this resolved the problem.
这篇关于为什么junit测试不能与"sbt测试"一起执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文