Reputation: 11
I want to use Step name which is mentioned in Scenario/Scenario Outline feature file. So please help me how to get the step information in Cucumber java.
Upvotes: 1
Views: 962
Reputation: 90
You can use Hooks to get the scenario object and then its name. Should be something like this
package util;
import cucumber.api.java.Before;
public class Hooks {
public String scenario_name;
@Before
public void getScenario(Scenario){
scenario_name = Scenario.getName();
}
}
and then, don't forget to add util, in that case, to your glue
@CucumberOptions(...glue = {"yourStepPackage","util"}...)
Hope it helps!
Upvotes: 1