Reputation: 233
we are using cucumber java for implementing component tests in our project.below is the test runner class.
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format={"pretty"})//, features="classpath:component/features/*.feature")
public class RunAllComponentCukesTest {
}
When I run component tests through this class,it was working fine.Now its not.I don't know whats wrong with this.I thought it might be with class path issue.I changed path and I just run all tests but in any way it's not working.If run from command prompt it is working fine.
I am getting following error message:
cucumber.runtime.CucumberException: Failed to create scenario runner
at cucumber.runtime.junit.FeatureRunner.buildFeatureElementRunners(FeatureRunner.java:85)
at cucumber.runtime.junit.FeatureRunner.<init>(FeatureRunner.java:31)
at cucumber.api.junit.Cucumber.addChildren(Cucumber.java:90)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
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)
Caused by: org.junit.runners.model.InitializationError
at org.junit.runners.ParentRunner.validate(ParentRunner.java:418)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
at org.junit.runners.Suite.<init>(Suite.java:112)
at cucumber.runtime.junit.ExamplesRunner.<init>(ExamplesRunner.java:19)
at cucumber.runtime.junit.ScenarioOutlineRunner.<init>(ScenarioOutlineRunner.java:21)
at cucumber.runtime.junit.FeatureRunner.buildFeatureElementRunners(FeatureRunner.java:81)
... 21 more
I searched in google but this problem looks more generic so couldn't get the answer.
Upvotes: 1
Views: 4270
Reputation: 1
Got to Help/About Eclipse, click on "Installation Details". Select "Cucumber Eclipse Feature" and click in "Update...". Don't worry if your plug-in is up to date...
Now open your POM file (Maven Project) and set artifacts "cucumber-java", "cucumber-jvm" and "cucumber-junit" to version 1.2.2 at least (junit must be at least 4.11).
Upvotes: 0
Reputation: 1229
This is an old question but just in case anyone happens to land here the solution is to use cucumber-junit 1.2.2
Ref: https://github.com/junit-team/junit/issues/1083
Upvotes: 1
Reputation: 21
I started getting this error seemingly out of the nowhere as well.
Problem: It looks like there is an incompatibility between cucumber.runtime.junit.ExamplesRunner and org.junit.validator.PublicClassValidator from junit-4.12-beta-1.jar.
PublicClassValidator throws an Exception with message:
"The class cucumber.runtime.junit.ExamplesRunner is not public."
I was only able to see this message displayed by stepping through with the debugger.
I was importing the latest 4.+ version of junit which is currently 4.12-beta-1. That is why the problem seemed to come out of nowhere. I guess I had not refreshed my dependencies in a while.
Solution: I reverted back to junit-4.11.jar and the error is no longer happening.
Upvotes: 2
Reputation: 233
I changed the version of the eclipse it works fine in new eclipse.But I couldn't figure out what exactly the problem
Upvotes: 0