views:

211

answers:

1

I'm developing Scala code using Eclipse, often when I run tests I get this error:

No tests found with test runner 'JUnit 3'.

Environment:

  • Eclipse for Java Developers, 3.5.1
  • Scala 2.7.7
  • JUnit 4.7

I'm currently writing my tests as JUnit3 tests, and invoking them by right clicking on a package in the project explorer, choosing Run As -> JUnit Test. (I was writing them as JUnit4 tests but ran into even more problems.)

If I fire up eclipse, the tests may not run unless I first open the source code file for the test. If I do open the source code file for the test, it will run. However, often then when I make any modification to the test file or any other source code file, Eclipse will refuse to run my tests, saying: "No tests found with test runner 'JUnit 3'."

I just repeated this just now:

  1. Open eclipse
  2. Open the .scala file with some tests
  3. Invoke the tests by right clicking on the package for that file in the project explorer and choosing Run As -> JUnit Test
  4. It ran the tests
  5. One failed
  6. I changed a string literal in the failing test to fix it
  7. I then re-launced the test using the same method, and I get the dreaded "No tests found with test runner 'JUnit 3'."
  8. I get this same method using other methods of launching the tests, e.g. JUnit buttons or menus to re-run all or some tests

To get the tests to run again I close and re-open Eclipse... So I end up relaunching Eclipse many many times a day.

Note: I do often use XML literals in my tests, I wonder if that has anything to do with it.

2nd Note: See my answer to this thread: http://stackoverflow.com/questions/1517642/what-is-the-current-state-of-the-scala-eclipse-plugin/1681156#1681156 where I described some of the other problems I'm having with Scala+Eclipse. Most of the problems are just minor annoyances, but this test invocation problem is a real time waster, would love to find a way around it!

+3  A: 

This Just works on trunk ... JUnit 3 and 4 unit test are detected and Run As => JUnit test does the right thing.

Oh, and BTW, the best way to get my attention on this sort of thing is to file a bug or enhancement ticket in Trac rather than posting messages to StackOverflow (even though it worked this time ;-)

Miles Sabin
Thanks Miles, yes, I commented on the Trac issue: https://lampsvn.epfl.ch/trac/scala/ticket/1590. Having it work in the trunk is great, but doesn't help me :) Certainly looking forward to 2.8 though.
Alex Black
Any work arounds you can suggest on 2.7.7? Maybe based on your knowledge of the fix you might have some insight - it is odd that it works sometimes...
Alex Black
Prior to trunk intercepting this behaviour, the mechanism which the JDT used to search for annotations attempted to parse the searched source as if it were Java ... that sort of succeeded in some circumstances for some Scala sources, but success here would essentially be accidental.Before you ask, no, there's absolutely no chance of a backport to the 2.7.x branch.
Miles Sabin
Sounds like I will just have to be patient, thanks.
Alex Black