• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about running Junit test's in eclipse.

 
Justin Allen
Greenhorn
Posts: 18
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(BlockJUnit4ClassRunner.java:158)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:349)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

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
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin,
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.
 
Justin Allen
Greenhorn
Posts: 18
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


thanks

Justin
 
Justin Allen
Greenhorn
Posts: 18
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES! It worked, i think it was deleting and re-creating my run configuration. Thanks so much for your help!!!
 
Arvind Arya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try rename your test class and retest. Hopefully it will work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic