Not supposed to?
The reason you would want it is for traceability and explainability.
Very helpful for debugging, too.
Especially when you have more than 20 gherkin files (with up to 200 steps) and more than 20 step definition files.
I put one of these at the top of every Java step definition file:
@Before
public void printScenarioName(Scenario scenario) {
this.scenario = scenario;
this.featureName = CukeUtils.getFeatureName(scenario);
String result = "@Before:\n*************Setting Feature: " + this.featureName +
"\n*************Setting Scenario: " + this.scenario.getName();
log.info(result);
}
where in CukeUtils I have defined:
public static String getFeatureName(Scenario scenario) {
String featureName = "";
System.out.println("scenario.getId(): " + scenario.getId());
// Usually the scenario Id is doctored version of the lines following
// the Feature: and the Scenario: keywords.
// Eg.: scenario.getId(): a-long-(20-minute)-non-invasive-smoke-test-that-
//comfirms-that-i-can-login-to-area51-via-the-nasa-portal;as-a-superuser-i-
//must-be-able-to-login-to-area51-via-the-nasa-portal-so-that-i-can-access-
//all-the-secret-files
String rawFeatureName = scenario.getId().split(";")[0]
.replace("-i-", "-I-").replace("-"," ");
featureName = featureName + rawFeatureName.substring(0, 1).toUpperCase() +
rawFeatureName.substring(1).replace("nasa", "NASA");
return featureName;
}