No tests found with test runner 'JUnit 4'

My Java test worked well from Eclipse. But now, when I relaunch test from the run menu, I get the following message:

No tests found with test runner 'JUnit 4'

In the .classpath file I have all jar files, and at the end have:

<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

How can I resolve this error and get tests running again?


Solution 1:

this just happened to me. Rebuilding or restarting Eclipse didn't help.

I solved it by renaming one of the test methods to start with "test..." (JUnit3 style) and then all tests are found. I renamed it back to what it was previously, and it still works.

Solution 2:

When we get these errors it seems like Eclipse is just confused. Restart Eclipse, refresh the project, clean it, let Eclipse rebuild it, and try again. Most times that works like a charm.