如何在intelliJ 12中定义黄瓜的步骤定义位置

the*_*ome 9 grails intellij-idea cucumber geb

我有我feature filessrc/resources/com/features和我step definitionssrc/main/java/com/step_definitions

我的测试都运行正常,但是即使我要求它创建一个新的,因此,intelliJ拒绝查看步骤defs的位置.这个配置在哪里?

ben*_*ape 11

我只是用完全相同的问题撕掉我的头发(记录我的背景是Java,Ruby,Cucumber和RubyMine,但我是IntelliJ和Cucumber-JVM的新手).

在Cucumber-JVM中,run configuration必须glueIntelliJ文档中提到的字段中指定存储步骤定义的包.IntelliJ - 至少对我来说 - 似乎没有提供默认值.

进一步详细说明,一个非常基本的项目如下所示:

Example
????src
    ????main
    ?   ????java
    ????test
        ????java
        ?   ????com
        ?       ????bensnape
        ?           ????example
        ?                   MyStepdefs.java
        ????resources
                example.feature
Run Code Online (Sandbox Code Playgroud)

glue这里的价值是com.bensnape.example.

更新

在今天早上更多地使用IntelliJ之后,如果你坚持使用Cucumber-JVM惯例,它似乎确实glue为你提供了价值 - 即功能必须存在,src/test/resources/<package>并且类似地,步骤必须存在src/test/java/<package>.

示例项目树:

Example
????src
    ????main
    ?   ????java
    ????test
        ????java
        ?   ????com
        ?       ????bensnape
        ?           ????example
        ?                   MyStepdefs.java
        ?
        ????resources
            ????com
                ????bensnape
                    ????example
                            example.feature
Run Code Online (Sandbox Code Playgroud)


Pra*_*thy 3

默认约定是step definitions在. 子文件夹的名称并不重要;无论名称是什么,它的工作原理都是一样的。step_definitions sub-folderfeatures directory

我的猜测是,IDE 将遵循相同的约定,因此如果将 step_definitions 文件夹移动到 features 文件夹下,IntelliJ 应该正确执行这些功能。

在执行功能之前,可以选择需要文件cucumber command-r该选项可用于使其在非常规位置查找step_definitions。

我猜您可能-r src/main/java/com/step_definitions在本地配置上有黄瓜,以便在从命令行调用时看到这些step_definitions。

运行cucumber --verbose显示命令行在何处查找步骤定义代码。