File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Question about running Junit test's in eclipse. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Question about running Junit test Watch "Question about running Junit test New topic

Question about running Junit test's in eclipse.

Justin Allen

Joined: Feb 02, 2011
Posts: 18

I'm trying to setup eclipse to run Junit tests. I have created this simple test-class :

I setup junit to run this test but I get this exception when running:

java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(
at org.junit.runners.ParentRunner.validate(
at org.junit.runners.ParentRunner.<init>(
at org.junit.runners.BlockJUnit4ClassRunner.<init>(
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(
at org.junit.internal.requests.ClassRequest.getRunner(
at org.junit.internal.requests.FilterRequest.getRunner(
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

I'm obviously doing something wrong, but I haven't been able to pinpoint what. Any help would be greatly appreciated.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33117

Your example works for me. Some things I can think of to try:

1) Remove the unused imports:

These imports are from JUnit 3.8. I don't think this will solve the problem, but it is confusing matters.

2) Go to "run configurations" and delete this test under JUnit. I'm thinking it might be remembering your test from when it was formerly a JUnit 3.8 test. (I assume that's why TestCase is in your code.)

As an aside are EventManager and ListLookup in the default package? This could cause you naming conflicts one day. It really should go in a named package.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Justin Allen

Joined: Feb 02, 2011
Posts: 18

Jeanne, thank you for your response, I will give your idea's a try. FYI, ListLookup and EventManager are in named packages, I just took them out because I work for a major company and wouldn't want anyone getting upset if they saw my code on this website. I do have them imported correctly, I just dropped them for the sake of this post.


Justin Allen

Joined: Feb 02, 2011
Posts: 18

YES! It worked, i think it was deleting and re-creating my run configuration. Thanks so much for your help!!!
Arvind Arya

Joined: Oct 11, 2007
Posts: 1
Try rename your test class and retest. Hopefully it will work.
I agree. Here's the link:
subject: Question about running Junit test's in eclipse.
It's not a secret anymore!