cybtow
cybtow

Reputation: 157

Java Cucumber: Specify target tags in the definition steps

Is it possible to specify a (or several) target tags in the definition steps?

For instance, I have two features:

feature1.feature
@feature1
...
And I click on "save" button
...

feature2.feature
@feature2
...
And I click on "save" button
...

Both features are using the same glue files (they have a lot of common steps).

And I need that these steps have a different implementation for the rule:

@And("^I click on \"([^\"]*)\" link$")

How can i do this? Is there any annotation to specify that a definition step is used only for a (or several) tags? I would to do something like this:

@And("^I click on \"([^\"]*)\" link$")
@Something("@feature1")
public void i_click_on_link_feature1(String option) {
    ...
}

@And("^I click on \"([^\"]*)\" link$")
@Something("@feature2")
public void i_click_on_link_feature2(String option) {
    ...
}

Upvotes: 0

Views: 1932

Answers (1)

Grasshopper
Grasshopper

Reputation: 9058

You will not be able to differentiate step definitions based on feature file tags. Suggest you change the wording of the steps where you want different step definition method. Only the Before and After hooks take feature file tags which in your case will not serve any purpose

Upvotes: 1

Related Questions