how to define step definitions location for cucumber in intelliJ 12

theawesome picture theawesome · Dec 21, 2012 · Viewed 18.8k times · Source

I have my feature files in src/resources/com/features and my step definitions in src/main/java/com/step_definitions

My tests all run correctly, but intelliJ refuses to see where the step defs are, even if I ask it to create a new one. Where is this configured?

Answer

ben.snape picture ben.snape · Dec 28, 2012

I was just tearing my hair out with exactly the same problem (for the record my background is Java, Ruby, Cucumber and RubyMine but I'm completely new to IntelliJ and Cucumber-JVM).

In the Cucumber-JVM run configuration you must specify the package where the step definitions are stored in the glue field as mentioned in the IntelliJ documentation. IntelliJ - for me at least - does not seem to provide a default value.

To elaborate further, a very basic project looks like this:

Example
└───src
    ├───main
    │   └───java
    └───test
        ├───java
        │   └───com
        │       └───bensnape
        │           └───example
        │                   MyStepdefs.java
        └───resources
                example.feature

The glue value here would be com.bensnape.example.

Update

After playing with IntelliJ some more this morning, it seems that it does provide the glue value for you if you adhere to the Cucumber-JVM conventions - i.e. the features must live under src/test/resources/<package> and similarly, the steps must live under src/test/java/<package>.

Example project tree:

Example
└───src
    ├───main
    │   └───java
    └───test
        ├───java
        │   └───com
        │       └───bensnape
        │           └───example
        │                   MyStepdefs.java
        │
        └───resources
            └───com
                └───bensnape
                    └───example
                            example.feature