找不到黄瓜步骤定义 - InteliJ Gradle

时间:2016-08-04 12:23:31

标签: intellij-idea gradle cucumber bdd cucumber-java

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

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强调给予,等等作为缺失的步骤定义。我生成定义,而InteliJ仍然无法识别它们。我正在使用Cucumber gradle plugin进行以下配置:

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

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

2 个答案:

答案 0 :(得分: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']
    }
    
  3. 如果出现任何问题,您可以尝试在选项中使用classpath:

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

    }

答案 1 :(得分:0)

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

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