views:

106

answers:

2

I have a strange issue with JUnit 4 tests in Eclipse 3.5 that I couldn't solve - any hints gratefully received!

Initially: I had a test suite working properly, with 100+ tests all configured with JUnit 4 annotations. I'd run these typically by right clicking on my source folder and selecting "Run as JUnit test". All worked perfectly.

Now: When I try to run the test messages all I get is an error "No tests found with test runner 'JUnit 4'".

Any idea what is happening? I simply can't work out what could have changed to make this fail.

My guess is that it is some configuration issue based on the build path or class path?

+1  A: 

My first couple of thoughts (without seeing some example test code):

http://stackoverflow.com/questions/2332832/no-tests-found-with-test-runner-junit-4

A lot of suggestions state to restart Eclipse and clean project. In my experience, sometimes eclipse gets stuck in a mode where it thinks I am trying to do a hybrid run between JUnit 3 and 4, so naming the '@Test' method with the old verbiage of naming it 'test...' sometimes works.

Also if you have any other plugins, i.e. m2eclipse, or other that you have recently added, this could effect your situation as well. If anything you have recently added uses its own version of JUnit, this could cause issues.

Some sample test code, might help with further investigation.

__nv__
Thanks - I did check that thread but none of the tips there seemed to work (restart eclipse or clean project didn't work, I'm not using Maven).
mikera
Also most of the tests are already named something like "@Test public void testXXX()" so probably isn't the 3/4 confusion issue.
mikera
Hmm... try getting rid of the 'test' keyword and running just one test case individually, does that work?
__nv__
Also, since it seems to be a project configuration issue, do you have the same 'working directory' between the 2 projects for your JUnit configuration (arguements tab)? I believe it defaults to ${workspace}.
__nv__
I have ${workspace_loc:ProjectName} as the working directory (which is the default). All the code is then under the src subdirectory. Could that be an issue?
mikera
A: 

I never found out the real cause of this issue but an upgrade to Eclipse 3.6 finally solved it.

mikera