【问题标题】:Step does not have a matching glue code error in cucumber eclipse黄瓜日食中步骤没有匹配的胶水代码错误
【发布时间】:2016-04-04 10:26:42
【问题描述】:

我正在尝试运行下面提到的功能文件。

Feature: Prove the concept of my script

  Scenario: My first Test
    Given This is my first step
    When This is my second step
    Then This is my third step

当我运行这个功能文件时,它给出了一个错误,说明如下,并且步骤已用“步骤没有胶水代码”的语句突出显示。

错误如下所示。我想运行上面的功能文件并了解该功能的缺失文件。

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

拜托,我是黄瓜的初学者,我想解决这个问题。如果可以,请帮助我。

【问题讨论】:

    标签: java eclipse cucumber cucumber-jvm cucumber-junit


    【解决方案1】:

    您的异常告诉我您缺少依赖项。

    我会克隆 https://github.com/cucumber/cucumber-java-skeleton 或将其下载为 zip 并启动​​并运行。希望这能说明您的设置有什么问题。

    【讨论】:

    【解决方案2】:

    这个问题的发生是因为在你的 Eclipse 设置中缺少小黄瓜内部的编码。 您必须安装最新版本的小黄瓜。 可以从 Marven 存储库中找到最新的可用小黄瓜。 下载最新版本后,将该gherkin jar文件导入黄瓜项目。

    【讨论】:

      【解决方案3】:

      请添加以@符号开头的黄瓜标签,如下所示

      @featureTest
      Feature: Prove the concept of my script
      
      @Scenario1
        Scenario: My first Test
          Given This is my first step
          When This is my second step
          Then This is my third step
      

      确保特征文件中的单词与 Given、When 和 Then 的 Step 定义 java 文件中的“As is”相匹配

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-05-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多