I am using common step method;
public void performAction(String actionText) {
//code to access actionText
}
Now I want to call this method in 2 ways. In the 1st case, I say;
I select action %action_text_taken_from_properties_string
Here I specify the annotation as
@When("I select action $actionText")
and inside performAction(), I use a custom processStepString() to get the actual value from a string properties file
Now in the 2nd case, I say;
I select action <action_text>
Here I use the Examples table to pass the value for action_text
So my annotation looks like
@When("I select action <action_text>")
But this requires me to have the signature as
public void performAction(@Named("action_text") String actionText)
My question is how do I use the same performAction() for both the cases ?
Seems you are using BDD driven approch, but you didnt specified what process you are using either Jbehave or Cucumber. I am assuming that you are using Jbehave. In Jbehave You can use @Alias Annotation like this
you can refer This Link for more info.
please let me know if it works .