No tests found with test runner 'Scala JUnit 4'

482 views
Skip to first unread message

Erick Hagstrom

unread,
Apr 7, 2015, 2:19:50 AM4/7/15
to scala-i...@googlegroups.com
This seems to be a recurring issue here in one form or another. Sorry to bring the news that it is still an issue.

Our tests are written in Scala and reside in their own Eclipse plug-in. They test Java code from another plug-in. We have three test classes, each residing in its own .scala file. The package name does NOT match the name of the plug-in, it matches the package in which the classes under test reside. All three test classes are in the same package. All of our test classes are annotated with @RunWith(classOf[JUnit4]), and all of our test methods are annotated with @Test. We launch our tests from the IDE using an Eclipse Run Configuration that invokes the Scala Junit4 test runner. The run configuration is configured to "Run all tests in the selected project, ...", where it is the test plug-in project that is selected.

If I open my Eclipse IDE, and none of the test classes are open in an editor,
When I invoke my run configuration,
Then I get the message found in the Subject above: No tests found with test runner 'Scala JUnit 4'

If I then open ONE of the test classes in an editor,
When I invoke my run configuration,
Then only the tests found in that class run, and there is no indication that the other two were skipped.

As you can imagine, opening the other two test classes in an editor results in all of my tests running.

I've tried moving my test classes to a package whose name matches that of the plug-in project, but that doesn't help.

I'd like all of my tests to run without having to open the test classes in an editor. Any ideas?

Thanks

Arnaud

unread,
Apr 7, 2015, 11:51:55 AM4/7/15
to scala-i...@googlegroups.com
I have observed something similar. Sometimes I have to open the .scala file so that the test class is detected by Eclipse.

Simon Schäfer

unread,
Apr 7, 2015, 4:35:01 PM4/7/15
to scala-i...@googlegroups.com
I don't know why the tests are not automatically found, probably a bug in our JDT integration.

You should be able to solve the problem by using a junit suite:

@RunWith(classOf[Suite])
@Suite.SuiteClasses(Array(
  classOf[Test]
))
class TestsSuite

Just register all your tests there and run the suite with junit.

Thanks
--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/90d281e7-3912-40f4-b8fc-2026ac408d09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arnaud

unread,
Apr 8, 2015, 4:34:43 AM4/8/15
to scala-i...@googlegroups.com
I see the problem (randomly) when I want to run a single test class (not all tests in a package), a plain class with a few @Test methods.

Erick Hagstrom

unread,
Apr 9, 2015, 6:51:54 PM4/9/15
to scala-i...@googlegroups.com
Thanks Simon. That did it. For anyone else reading, it's important to run the suite with JUnit4, NOT Scala JUnit 4. (I made that mistake the first time around. :-( )

Hope you guys can track down that bug. Meanwhile, the Suite approach will do what I need.

iulian dragos

unread,
Apr 10, 2015, 4:01:06 AM4/10/15
to scala-i...@googlegroups.com
On Fri, Apr 10, 2015 at 12:51 AM, Erick Hagstrom <erick.h...@hii-nns.com> wrote:
Thanks Simon. That did it. For anyone else reading, it's important to run the suite with JUnit4, NOT Scala JUnit 4. (I made that mistake the first time around. :-( )

This sounds like a regression. `Scala JUnit4` was added precisely because JUnit4 wasn't able to find all tests, and on top of that it was dead-slow.

iulian
 

Hope you guys can track down that bug. Meanwhile, the Suite approach will do what I need.

On Tuesday, April 7, 2015 at 4:35:01 PM UTC-4, Simon Schäfer wrote:
You should be able to solve the problem by using a junit suite:

@RunWith(classOf[Suite])
@Suite.SuiteClasses(Array(
  classOf[Test]
))
class TestsSuite

Just register all your tests there and run the suite with junit.

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

iulian dragos

unread,
Apr 30, 2015, 10:28:55 AM4/30/15
to scala-i...@googlegroups.com
I found a regression involving scaladoc comments. If the test class has a scaladoc comment it is not recognized as a test. I filed #1002442 and hope that a fix can still make it in 4.1

iulian dragos

unread,
Apr 30, 2015, 10:32:29 AM4/30/15
to scala-i...@googlegroups.com
https://github.com/scala-ide/scala-ide/pull/937 if anyone wants to give a hand with a code review ;-)
Reply all
Reply to author
Forward
0 new messages