I am using sbt version 0.13.2 with a pure java project.
My build.sbt
has the following line in it:
libraryDependencies ++= Seq("com.novocode" % "junit-interface" % "0.10" % "test")
My test looks like this:
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);
}
}
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?
Sometimes it so happens that our code is not completely ready while running a test case. As a result, the test case fails. The @Ignore annotation helps in this scenario.
The following commands will make sbt watch for source changes in the Test and Compile (default) configurations respectively and re-run the compile command. Note that because Test / compile depends on Compile / compile , source changes in the main source directory will trigger recompilation of the test sources.
When I remove the @RunWith
annotation, my tests run just fine. I don't know why this resolved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With