【问题标题】:Cucumber feature file does not identify the steps黄瓜特征文件不识别步骤
【发布时间】:2016-06-04 12:58:07
【问题描述】:

我已经编写了我的耐寒黄瓜功能文件。当我将功能文件作为 Cucumber Feature 运行时,出现以下错误

  1. “警告:Cucumber-JVM 的 --format 选项已弃用。请改用 --plugin。” - 我在跑步者类的@CucumberOptions 中使用了“插件”,但仍然遇到同样的错误

2.它说我没有任何场景和步骤 功能:验证模块化 GUI 页面

场景:验证登录页面#C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 给定:模块化 GUI 已打开 时间:验证登录页面 然后:登录到模块化

0 场景 0 步

  1. 我的步数没有得到 sn-ps。

我已将以下 jar 添加到库中 Jars

这是我的跑步课, 包图形界面;

import org.junit.runner.RunWith;

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

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

}

这是我的功能文件,

Feature: Validate Modular GUI pages

  Scenario: Validate Login Page
    Given: Modular GUI is opened
    When: Validate the login page
    Then: Login to the Modular

如果有人能指出我的代码中缺少的内容,我将不胜感激。

非常感谢

[已编辑] 这是实际的错误:

警告:Cucumber-JVM 的 --format 选项已弃用。请用 --plugin 代替。功能:验证模块化 GUI 页面

场景:验证登录页面# C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 给定:模块化 GUI 已打开 何时:验证登录页面 然后:登录到模块化

0 场景 0 步 0m0.000s

【问题讨论】:

    标签: java eclipse selenium cucumber gherkin


    【解决方案1】:

    在 Given、When 和 Then 之后,我的功能文件中多了一个“:”。

    现在可以了。

    【讨论】:

      【解决方案2】:

      您的类路径中缺少功能文件。

      你没有告诉我们你是如何运行 Cucumber 的。但是,如果您将它作为 Maven 构建的一部分运行,这是更简单的选项之一,您希望将功能文件存储在

      ./src/test/resources/GUI

      一个简单的入门方法是从 GitHub 下载入门项目,https://github.com/cucumber/cucumber-java-skeleton

      它将为您提供一个工作项目,您可以对其进行修改以包含您的问题。

      【讨论】:

      • 谢谢@Thomas Sundberg 我不使用 Maven,我只是使用空项目构建它。关注youtube.com/watch?v=pD4B839qfos 的instaruction 我没有收到来自 youtube 海报的反馈 感谢您抽出宝贵时间。
      • 目前我的功能文件位于 src\GUI\features,我也尝试过您提到的位置。我仍然遇到同样的问题
      【解决方案3】:

      您的步骤定义位于何处?尝试添加标签“胶水”,如下所示

      @RunWith(Cucumber.class)
      @CucumberOptions(
              format = {"pretty", "json:target/"},
              features = {"src/GUI/"},
              glue = {"path/to/steps"} 
              )
      public class GUIRunner {
      
      }
      

      【讨论】:

        【解决方案4】:

        只是添加到现有答案:记住在编写步骤的实际代码之前写“场景:”。这可能看起来微不足道,但如果没有它,您将始终收到“0 个功能,0 个步骤”的消息。

        来源:https://www.youtube.com/watch?v=WuTKWwD37Tg

        【讨论】:

          【解决方案5】:

          请加tags = {"@SmokeTest"}tags = {"@RegresionTest"}

          【讨论】:

            【解决方案6】:

            请在@CucumberOptions()中添加tags= {"@SmokeTest","@RegressionTest"}

            【讨论】:

              【解决方案7】:

              format 替换为 plugin,因为格式选项从 v1.2.0 起已于 2014 年 10 月 30 日弃用。下面的例子 -

              @RunWith(Cucumber.class)
              @CucumberOptions(features = "classpath:features/functional/",
                                   glue = {"com.jacksparrow.automation.steps_definitions.functional" },
                                 plugin = { "pretty","json:target/cucumber-json/cucumber.json",
                                          "junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
                                 tags = { "@BAMS_Submitted_State_Guest_User" },
                                 strict = false,
                                 dryRun = false,
                             monochrome = true)
              

              【讨论】:

                猜你喜欢
                • 2014-01-10
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多