Home > Enterprise >  Duplicate Annotations for cucumber in Java BDD framework
Duplicate Annotations for cucumber in Java BDD framework

Time:01-13

Below three @Then statement coming from different step definition how to resolve this in Java.

@Then("User selects {string} value")
@Then("User selects {string} and verify the value are Present in the dropdown")
@Then("User selects {string} value under placements")
public void user_selectsValue(String locatorString) throws Throwable {
    locatorStr =  POC_homePageMenuItems.mainButtonDropdownNewfrmData(locatorString);
    elementclick(locatorStr);
    }

How to get this issue resolved, in python duplicate @Then with different step definition is allowed. How to resolve this in Java

enter image description here

CodePudding user response:

You could use a regex OR grouping

@Then("User selects {string} (value|value under placements|and verify the value are Present in the dropdown)")
public void user_selectsValue(String locatorString, String option) throws Throwable {

but probably simpler to refactor to a single test phrase if the new option is not used/needed.

CodePudding user response:

I guess you're using an old version of Cucumber. Since Cucumber v5 the step definition annotations are repeatable

  • Related