Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains


Cucumber for Java and Groovy in IntelliJ IDEA 12

Inspired by support for Cucumber in RubyMine and by Aslak’s suggestions, we’ve added Cucumber support for Java and Groovy.

With IntelliJ IDEA 12 now it’s easy to navigate from a step to its definition, look for a step’s usage and run .feature tests.

Here I’ll briefly describe how you can create a scenario, step definitions in Java and run a Cucumber test.

Let’s start with the java-calculator project from Cucumber-JVM’s examples. Suppose we want to create a scenario to test the subtraction.

We open basic_arithmetic.feature and write the following scenario:

Scenario: Subtraction
When I subtract 5 from 9
Then the result is 4

The IDE will highlight the step “When I subtract 5 from 9” immediately, because there is no such definition:

A quick-fix will propose to create a step definition:

We select a class that would be the container of the new step definition, and press Enter. IntelliJ IDEA will create a template with the step definition:

Now we are ready to implement the logic.

The next step is to run the file basic_arithmetic.feature. Let’s open it and select Run Feature: basic_arith… from the context menu:

After the run console window appears, you can see the results:

Cucumber for Java and Groovy is available in IntelliJ IDEA 12 Preview for free download and evaluation.

As always, your suggestions and feedback are very much welcome in our issue tracker.

Develop with Pleasure!

Comments below can no longer be edited.

20 Responses to Cucumber for Java and Groovy in IntelliJ IDEA 12

  1. Avatar

    jtonic says:

    November 12, 2012

    Useful feature for IDEA

    I’ve tried the example in IDEA Leda 12 122.746 and I came across a NPE (see, so I didn’t manage to create a step definition.


  2. Avatar

    Max says:

    December 7, 2012

    Great work! It also does auto-complete of scenario steps! Go Cucumber!

  3. Avatar

    Bill Wright says:

    December 10, 2012

    I just downloaded the Community Edition 12 because of this increased cucumber support (I use the Ultimate Edition 11 now). These cucumber enhancements seem to be listed for either version. Yet when I bring up my existing cucumber project I see no sign of any cucumber integration at all. Not even syntax highlighting.

  4. Avatar

    Michael Dwyer says:

    December 12, 2012

    I too am missing the highlighting, just downloaded the latest Community edition.

  5. Avatar

    Priya says:

    December 20, 2012

    I am using intellij ldea ultimate edition 12
    Scenario-Not able to use double quotes in the middle of string:
    While writing scenarios I am not able to add double quotes in the mid of string.Is there any special character required to append with double quotes?
    And string “He”ll”o” added to string “World2”

  6. Avatar

    Gareth Fleming says:

    January 9, 2013

    Although Cucumber support is listed in the feature list published on the main site for both versions of the IDE, the feature list on the EAP site ( would suggest that Cucumber support is only available in Ultimate.

  7. Avatar

    Jonas says:

    January 20, 2013

    I have Cucumber integration working for feature files that are written in English (using the English Gherkin keywords: Feature, Scenario, Given, When, Then …).

    However I can’t get the integration working with feature files that are written in another language. i.e. German (using the German Gherkin keywords: Funktionalität, Szenario, Wenn, Dann …).


    Are non-english feature files supported? How?

    Thanks for the info.

  8. Avatar

    Alex says:

    March 5, 2013

    Is it possible to get some clarification on what edition ‘Cucumber for Java and Groovy’ is or will be in? When I look at the comparison matrix, Cucumber support is not even listed (for either edition). Thanks.

  9. Avatar

    Andrey Cheptsov says:

    March 6, 2013

    @Alex, Cucumber for Java and Groovy is only available in Ultimate at the moment. We will fix the comparison matrix page shortly.

  10. Avatar

    Divya Ashok says:

    March 27, 2013

    Will Cucumber integration be available for the community edition anytime ?

  11. Avatar

    Paul says:

    April 8, 2013

    Hi, I’m trying to get the Cucumber support working in IntelliJ IDEA 12.0.4 Ultimate. My features are not recognized (no syntax highlighting) in an existing project, and when creating a new Maven project (with Cucumber for Java plugin enabled), and adding the Cucumber dependencies, there is still no recognition. All the pages I found by googling imply that “it just works”, but I don’t see it so far. Anything else I need to do?

  12. Avatar

    Paul says:

    April 9, 2013

    Following on from my comment yesterday, I found that the pattern “*.feature” was not assigned to the “Cucumber scenario files” file type (in Settings -> File Types). When I assigned it correctly, it works fine.

  13. Avatar

    Rogelio says:

    April 14, 2013

    In my settings *.feature is correctly assigned to Cucumber but still loose the highlight and support on them. Had it working previously but lost it after a module re-import.
    Using #language: es and #encoding: utf-8 on the file but don’t think this matters.

  14. Avatar

    Anatoly says:

    April 29, 2013

    I’d like to ask you to vote for the feature you are talking about here:

  15. Avatar

    Bill Wright says:

    May 20, 2013

    The Cucumber integration works nicely in the full version, but there is a serious drawback – or at least I don’t know how to work around it. I want to re-use steps from a dependency jar and I list that in my Maven dependencies and can run the cucumber scenarios fine, as long as I use a JUnit runner class and specify the class path to the step classes. Is there a way to specify this class path to step classes within the IDE as well? Right now IntellliJ seems to only find steps defined in the module itself. I’d love a way to work around this and it would make this feature useful to me. As it stands, it is only a slick demo and not a real-world feature for me.

  16. Avatar

    Bill Wright says:

    May 21, 2013

    Actually, this is more complicated than I thought. You can specify where to find step classes and you do this via the run configuration via the “glue” field, which must be set but is not set automatically by IntelliJ, even when it creates the Step class for you. Once I manually set this glue field to the local package (the one used by IntelliJ when it automatically creates a step class for you) and any external packages (specified via Maven dependencies in my case), then when I run the scenario, steps are found and executed in both packages. That’s great, but the syntax highlighting of which steps are found and the step completion ONLY works on the local Steps class. So it will look like external steps are not defined, even though they are and will run fine when you run the scenario. It would be great if you could IntelliJ about external packages to search for steps…

    • Avatar

      Joel says:

      March 5, 2014

      Have you found a way to get this working? I’m facing the exact same situation.

      • Avatar

        Guillaume Berche says:

        March 13, 2014

        Isn’t this described into this issue with a suggested workaround ? If workaround not effective, what about voting for a fix or submit another issues ?

  17. Avatar

    Nick Evgeniev says:

    November 20, 2013


  18. Avatar

    Ole Christian Langfjæran says:

    May 5, 2014

    Are there any plans or roadmap of having this feature for Scala also?

Discover more