Hi,
I have a use case which requires me to capture the step name being executed, just like how you can do it with Scenario class. Here is the Hooks class content that I have:
public class Hooks {
TestContext testContext;
public Hooks(TestContext context) {
testContext = context;
}
@Before
public void beforeScenario(Scenario scenario) {
System.out.println("Executing before scenario for : " + scenario.getName());
}
@After
public void afterScenario(Scenario scenario) {
System.out.println("Executing after scenario for : " + scenario.getName());
}
@BeforeStep
public void beforeStep() {
System.out.println("In Before step...");
//TODO: Need to capture the Step which is going to execute
//Need some kind of implementation like step.getName()
}
@AfterStep
public void afterStep() {
}
}
I tried to pass in PickleStep object as an argument to beforeStep() method but seems like it only likes to have args of type cucumber.api.Scenario class (or no args). Is there anyway I can capture the current step name being executed in @BeforeStep annotation?
I am using cucumber-java - 3.0.2 (io.cucumber)
Thanks,
Anukul