0

我有以下问题。我的功能文件如下:

Feature: Serve coffee
  Coffee should not be served until paid for
  Coffee should not be served until the button has been pressed
  If there is no coffee left then money should be refunded

  Scenario: Buy last coffee
    Given there are 1 coffees left in the machine
    And I have deposited 1$
    When I press the coffee button
    Then I should be served a coffee

InteliJ 突出显示 Given 等作为缺少的步骤定义。我生成定义,但 InteliJ 仍然无法识别它们。我正在使用具有以下配置的Cucumber gradle 插件:

cucumber {
    formats = ['pretty','json:build/cucumber.json','junit:build/cucumber.xml']
    glueDirs = ['src/test/resources/step_definitions']
    featureDirs = ['src/test/resources/features']
}

我真的不确定我在那里做错了什么。提前感谢您的任何建议!

4

2 回答 2

0
  1. 尝试检查您是否在 Intellij Idea 中正确安装了 Cucumber for Java 插件。(设置/插件)。

  2. 尝试查看您的功能和粘合参数。Cucumber 默认会在 src/test/resources 文件夹和步骤定义中查找功能 - 到 src/test/java。(实际上在glueDirs 选项中,您已经设置了资源文件夹中步骤的路径)。因此,请尝试修改您的跑步者选项,例如:

    cucumber {
    formats = ['pretty','json:build/cucumber.json','junit:build/cucumber.xml']
    glueDirs = ['step_definitions']
    featureDirs = ['features']
    }
    

此外,如果出现任何问题,您可以尝试在选项中使用类路径:

cucumber {
formats = ['pretty','json:build/cucumber.json','junit:build/cucumber.xml']
glueDirs = ['classpath:step_definitions']
featureDirs = ['classpath:features']

}

于 2016-08-04T15:21:19.190 回答
0

IntelliJ 有一个 Cucumber 插件。确保已安装它。

在安装此插件之前,您的功能文件中的步骤将被标记为缺少步骤定义。

于 2016-08-05T10:28:36.420 回答