Serenity and JBehave is used for one test suite. I'm trying to get current story and scenario names for BrowserStack videos naming. As I read in the official documentation for this purposes used ContextView. I got code below from the official repository and changed it a little:
public class MyStory extends SerenityStories {
private final CrossReference xref = new CrossReference();
private Context context = new Context();
private Format contextFormat = new ContextOutput(context);
private ContextView contextView = new JFrameContextView().sized(640, 120);
private ContextStepMonitor contextStepMonitor = new ContextStepMonitor(context, contextView, xref.getStepMonitor());
@Override
public Configuration configuration() {
Configuration configuration = super.configuration();
configuration.useStepMonitor(contextStepMonitor);
return configuration;
}
}
After executing I saw JFrame window only with current step.
But context.getCurrentScenario();
and context.getCurrentStory();
always null.
All that I need is get scenario name before driver call and set in in the driver capability. What am I doing wrong? Maybe there's another way to do it?
P.S. serenity-jbehave 1.13.0, serenity-core 1.2.3-rc.5
You need to add an instance of ContextStoryReporter to your configuration:
configuration.storyReporterBuilder().withReporters(new ContextStoryReporter(context));