Search code examples
cucumbergherkincucumber-java

Step-definitions are not being found if I use newer Cucumber annotation interfaces like 'io.cucumber.java.en.Given'


I am trying to use new Cucumber libraries (v4.8.0) in my project code and facing issue with feature & step-definition linking.

I had previous project in which I was using older version of Cucumber (v1.2.5). Assuming that some setup was incorrect in my current project, I tried to match the Cucumber dependency in the previous project. But I encountered the same issue there as well

I also tried to verify the white spaces in my feature file, but had no success and the definitions were not identified

My Feature File:
    Feature: Feature Test
    Scenario: Scenario One
    Given Scenario One - Step One

My Definition File (using old annotation classes - definition gets identified):

 package definitions;
    import cucumber.api.java.en.Given;
    public class Feature1 {
        @Given("Scenario One - Step One")
        public void stepOne() {
        }
    }

My Definition File (using new annotation classes - definition does not get identified):

package definitions;
import io.cucumber.java.en.Given;
public class Feature1 {
    @Given("Scenario One - Step One")
    public void stepOne() {
    }
}

Expected results: I am expecting that the new annotation classes should be able to identify & link the feature step & definition

Actual results: Definitions gets identified if 'cucumber.api.java.en.Given' is used, but not identified if 'io.cucumber.java.en.Given' is used


Solution

  • updating the following packages cucumber version from 4.2.0 to 6.8.0

    Worked for me!