Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't junit tests get executed with "sbt test"?

Tags:

junit

sbt

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?

like image 613
mushroom Avatar asked May 31 '14 22:05

mushroom


People also ask

Why is JUnit ignoring tests?

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.

Does SBT test compile?

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.


1 Answers

When I remove the @RunWith annotation, my tests run just fine. I don't know why this resolved the problem.

like image 52
mushroom Avatar answered Oct 12 '22 11:10

mushroom