sbt / junit-interface

Implementation of sbt's test interface for JUnit
BSD 2-Clause "Simplified" License
133 stars 42 forks source link

Tests annotated using @RunWith not picked up by sbt #66

Open dmitrimedvedev opened 9 years ago

dmitrimedvedev commented 9 years ago

This test is not picked up:

@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:test-context.xml"}) public class MyTest {

but if @RunWith is commented out the test is picked up (but obviously does not work correctly)

//@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:test-context.xml"}) public class MyTest {

This is using 0.11 of junit-interface library libraryDependencies += "com.novocode" % "junit-interface" % "0.+" % "test" ... Resolving com.novocode#junit-interface;0.11-RC1

donhector commented 9 years ago

+1

In my case just using the plain Junit Parametrized.class runner

@RunWith(Parameterized.class) public class MyTest extends BaseTest { // code here }

My parametrized test ran (6 of them) but in the SBT console I see contradictory results:

[info] Test run finished: 6 failed, 0 ignored, 6 total, 70.937s [info] Passed: Total 0, Failed 0, Errors 0, Passed 0

My dependencies: "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.11" % "test -> default"

mknudsen commented 9 years ago

I think I've encountered this bug in my play project which seems to use this project (if I interpret https://github.com/playframework/playframework/blob/3c530e93603d4005211d466923fff486338faf00/framework/project/Dependencies.scala correctly).

As you can see in the linked issue from the play bugtracker the tests are run (and output to the console) yet they are not counted as either passed, failed or errors.

devosc00 commented 9 years ago

I have the same problem, when use @RunWith, I get zero value test report. [info] Passed: Total 0, Failed 0, Errors 0, Passed 0

mkotsbak commented 9 years ago

@RunWith(SpringJUnit4ClassRunner.class) works for me (in "IntegrationTest"). Have you tried the latest sbt version 0.13.8?

fommil commented 8 years ago

I've also seen the same problem (using org.scalatest.junit.JUnitRunner with the ScalaTest framework disabled), but it's only when the test extends from a class that has the RunWith annotation. When it's on the class directly, it works.

kovacshuni commented 7 years ago

Having the same issue. Having a class annotated with @RunWith(MockitoJUnitRunner.class), and sbt test doesn't run anything. Even if i comment it out, still won't run my JUnit 4 tests. I'm searching for the problem.

kovacshuni commented 7 years ago

managed to have it run by adding crossPaths := false in build.sbt.