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!

Discover more