Yug
Yug

Reputation: 11

How to get 'Step' name by using Cucumber with Java to use in Extent report

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

Answers (1)

AleT
AleT

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

Related Questions