带有Cucumber-JVM项目的java.lang.NoClassDefFoundError

时间:2015-04-10 07:01:17

标签: java junit cucumber

当我尝试将项目作为JUNIT项目运行时,我在java中收到此错误。当我转到我的功能文件并右键单击并以黄瓜功能运行时,我怎么能运行我的功能。

我该怎么做..?

这是错误的完整描述:

  

java.lang.NoClassDefFoundError:cucumber / runtime / PendingException at   cucumber.api.junit.Cucumber。(Cucumber.java:61)at   sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)     在   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)     在   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)     在   org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)     在   org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)     在   org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)     在   org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)     在   org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)     在   org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)     在   org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)     在   org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)     在   org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)     在   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)   引起:java.lang.ClassNotFoundException:   cucumber.runtime.PendingException at   java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)at   java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at   java.security.AccessController.doPrivileged(Native Method)at   java.net.URLClassLoader.findClass(URLClassLoader.java:354)at   java.lang.ClassLoader.loadClass(ClassLoader.java:425)at   sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308)at at   java.lang.ClassLoader.loadClass(ClassLoader.java:358)... 18更多

这是我的cucumberRunner文件

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber.Options(
        format={"pretty","json:target"},
        features={"src/features"}
    )

public class CucumberRunner {


}

1 个答案:

答案 0 :(得分:1)

试试这个:

import org.junit.runner.RunWith; import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
    format={"pretty","json:target"},
    features={"src/features"}
)

public class CucumberRunner {


}

“。”在CucumberOptions中是错误的