views:

290

answers:

1

Hi!

I am trying to create very simple eclipse plugin.

I want to run current selected test case, using my tool with a help of JUnit4TestAdapter.

When I run outside eclipse, using "main" with "parameters" everything is just fine.

When I invoke "main" with the same "parameters" inside the eclipse (i am creating separate thread for that invocation), I am getting following exception:

java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:171)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:115)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:269)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:66)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
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 junit.framework.JUnit4TestAdapter.<init>(JUnit4TestAdapter.java:31)
at junit.framework.JUnit4TestAdapter.<init>(JUnit4TestAdapter.java:24)
at util.JUnitTestRunner.runTest(JUnitTestRunner.java:26)
at master.Master.runTests(Master.java:180)
at master.Master.runTestsWithEquivalenceAnalysis(Master.java:207)
at master.Master.runInitialTests(Master.java:132)
at master.Master.run(Master.java:102)
at master.Master.runMutationTesting(Master.java:49)

Any idea, what actually is going wrong? Why BlockJUnit4ClassRunner decide to throw an exception when run outside of eclipse he is just fine with given test? Btw, actual test are JUnit 3.8 (as oppose to JUnit4)

+1  A: 

"No runnable methods" indicates that JUnit could not find any testable methods. For JUnit 3, this is methods starting with testXXX(); for JUnit 4, it is methods annotated with @Test.

JUnit does not run "main" methods, unless you are using JUnit 4 and the main method has the @Test annotation (which is pretty bad style).

If your methods do have these correct annotations and Eclipse is still throwing the same exception, this can be the result of a deeper problem with the classpath or configuration.

jevon