How to get name of scenario in cucumber java?
cucumber, cucumber-jvm, java
Solution
From version 1.6, in addition to, `getStatus()` and `getSourceTagNames()`, there is another method, `getName()` that returns the scenario's description. For example, for a scenario as follows:
Scenario: verify number of topics shown in the UI
`scenario.getName()` returns `"verify number of topics shown in the UI"`
I initialize scenario in @Before as follows:
@Before
public void before(Scenario scenario) {
this.scenario = scenario;
}
Hope this helps.
Problem
I would like to get name of scenario to have meaningful logs and to generate custom report at run-time in java. Scenario class have only has getStatus() and getSourceTagNames() methods. I don't find a way to get scenario name. Can someone help me to get this resolved ?