wood burning stoves*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Question about running Junit test Watch "Question about running Junit test New topic
Author

Question about running Junit test's in eclipse.

Justin Allen
Greenhorn

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(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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Justin Allen
Greenhorn

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.


thanks

Justin
Justin Allen
Greenhorn

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
Greenhorn

Joined: Oct 11, 2007
Posts: 1
Try rename your test class and retest. Hopefully it will work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about running Junit test's in eclipse.
 
Similar Threads
Problem creating mock using PowerMock
Junit with Testsuit error
Spring JUnit error
Class not found test.TestIndexBean error in Eclipse
DBUnit test class failure