3

I have a feature file with the following:

Scenario: Test something
 Given I do something to test something

My step definition:

import io.cucumber.java.en.Given;
...
@Given("I do something to test something")
public void doSomething()
{
....
}

From my pom.xml:

 <dependency>
 <groupId>io.cucumber</groupId>
 <artifactId>cucumber-testng</artifactId>
 <version>4.6.0</version>
 </dependency>
 <dependency>
 <groupId>io.cucumber</groupId>
 <artifactId>cucumber-java</artifactId>
 <version>4.6.0</version>
 </dependency>

With the above, I can run my code using my runner, but in the IDE (IntelliJ IDEA) the step in the feature file is complaining about an "Undefined step reference". When I CTRL-left-click the step, it does not take me to the method for the step.

If I change my import to:

import cucumber.api.java.en.Given;

Everything works as expected (i.e. the step is found), but then I get a warning about import cucumber.api.java.en.Given being deprecated (and the "Given" in my code has a line going through it).

enter image description here

How can I make my the feature file work so that when I CTRL-Left-Click on a step it will take me to the method for the step, but also avoid the "deprecated" warning?

asked Jul 18, 2019 at 12:44
4
  • Are you using IntelliJ Cucumber plugin? It may be due some mismatch over your Cucumber version. plugins.jetbrains.com/plugin/7212-cucumber-for-java (I will transform it in an answer if that's the case) Commented Jul 18, 2019 at 13:21
  • Hi @JoãoFarias. Unfortunately, the 192.x releases don't work with my version of IntelliJ (2019年1月3日). I'm downloading 2019.2, and will then try the latest version of the Cucumber for Java plugin. Commented Jul 18, 2019 at 14:08
  • 1
    Hi @JoãoFarias. Unfortunately, upgrading to the latest Cucumber for Java plugin did not work for me. The issue persists. When I use the deprecated packages (e.g. import cucumber.api.java.en.Given;), then everything works fine (except I get the "deprecated" warning and lines through deprecated annotations). Commented Jul 18, 2019 at 14:26
  • I did clean reinstall of IJ Idea 2019年3月4日 (193.6911.*) and installed latest plugins for that version Gherkin (193.*) and Cucumber for Java (193.*), but I still experience the same issues. My Cucumber package versions are 4.7.2. I don't have Substeps plugin as suggested in the answer below. Commented Mar 25, 2020 at 23:54

3 Answers 3

2

I had the exact same issue with our team's project. If you update to the latest version of IntelliJ (Currently 192.6x) it does support the latest version of the Cucumber for Java plugin now. After updating you will be able to change from using cucumber.api.java.en to io.cucumber.java.en

If you are updating from 191.x you may need to reinstall the Cucumber for Java plugin as well as update your other plugins such as gherkin.

answered Sep 11, 2019 at 14:41
2
  • it works for me Commented Nov 20, 2019 at 13:59
  • 1
    I'm on Idea 2019年3月4日 (193.*) with the latest plugins (also version 193.*) for it, but some steps are not mapped, while tests themselves work. Commented Mar 26, 2020 at 1:40
0

I also had a similar kind of issue in intelliJ.

In InjelliJ Settings -> Plugins (Ctrl+Alt+S), deselect the plugin Substeps IntelliJ Plugin. And install Cucumber for Java and Gherkin plugin. Restart IntelliJ.

answered Aug 15, 2019 at 7:25
0

Please go to FileType

Under Cucumber Scenario, Add *Feature. It will work.

Dont waste time in doing all other stuffs.

answered Mar 4, 2021 at 14:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.