线程“main”中的异常java.lang.NoClassDefFoundError:gherkin / lexer / Encoding

时间:2016-08-05 13:27:55

标签: java cucumber

嗨我在eclipse中运行我的功能文件时出错了。

我确实有最新的黄瓜罐还没有运气。关于如何解决的任何想法?我也指出了

这是我的代码:

package Cucumber;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

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

}

这是我的专题文件。

    Feature: My Feature
  Scenario: Title of your scenario
    Given This is my first test
    And This is my second test
    Then This is my final test

这是我收到的错误。

Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding
    at cucumber.runtime.FeatureBuilder.read(FeatureBuilder.java:154)
    at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:115)
    at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235)
    at cucumber.runtime.Runtime.run(Runtime.java:110)
    at cucumber.api.cli.Main.run(Main.java:36)
    at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 9 more

4 个答案:

答案 0 :(得分:1)

尝试将Cucumber-core,cumcuma-java和cumulan-junit jars设置为1.2.0,并使用小黄瓜2.12.2版,在几次失败后,这种组合对我来说都是有效的。

答案 1 :(得分:0)

解决了:我再次浏览了我的Jar文件并注意到Gherkin jar是一个公平的出路,所以我确实找到了最新的那个,而现在它运行正常。尽管如此,为你干杯。

答案 2 :(得分:0)

我找到了解决你们遇到的问题的方法。我下载了旧版的小黄瓜(2.9.3),最新版本是2.12.2。因此,请下载小黄瓜2.12.2并运行。

答案 3 :(得分:0)

使用最新版本的gherkin文件更新您的pom .xml文件可解决此问题。包括下面的依赖,但总是寻找最新的小黄瓜文件

         <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>gherkin</artifactId>
        <version>2.12.2</version>
         </dependency>