Search code examples
javaintellij-ideacucumbercucumber-java

Cucumber undefined step reference in Intellij


I have problem with Intellij 2019.2.4 Ultimate where I am unable to navigate from Cucumber feature file to glue code. Intellj is complaining of "Undefined Step Reference". Executing the cucumber test from console or via run configuration is however successfull.

Cucumber version 5.5.0 Junit version 4.13

Based on similary reported issues, this is what I have tried so far:

  • Verified that both Cucumber for Java and Gherkin plugins are enabled
  • Invalidate cache and restarted IDEA
  • Verified that SubSteps plugin is not enabled and in conflict with Cucumber for Java plugin
  • Reenable Cucumber for Java plugin

To illustrate my problem I have generated a simple project:

src/test/java/hellocucumber

package hellocucumber;

import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber"},
        features = {"src/test/resources/hellocucumber"},
        glue={"hellocucumber"},
        monochrome = true
)
public class RunCucumberTest {
}

my glue code

package hellocucumber;

import io.cucumber.java.en.Given;

public class StepDefinitions {

    @Given("today is Monday")
    public void today_is_Monday() {
        System.out.println("Today is monday");
    }
}

and my feature file: src/test/resources/hellocucumber/test.feature

Feature: This is a test

  Scenario: Today is or is not Friday
    Given today is Monday

Intellij complain of missing glue code:

enter image description here

I am lost and would much appreciate some input. Thanks

EDIT: Uploaded projectOneDrive

Also note, if I downgrade cucumber version from 5.5.0 to pre 5.x.x (e.g. 4.8.1) I am able to navigate from feature to glue!


Solution

  • This project works fine in IntelliJ IDEA 2019.3.3, please consider updating if you are using the recent Cucumber version.

    2019.3.3