JBehave空上下文

时间:2018-11-16 21:36:58

标签: java selenium jbehave serenity-bdd

Serenity和JBehave用于一个测试套件。 我正在尝试获取BrowserStack视频命名的当前故事和场景名称。 正如我在official documentation中所读 为此使用了ContextView。我从official repository处获得了以下代码,并对其进行了一些更改:

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;
  }

}

执行后,我仅在当前步骤下看到JFrame窗口。 但是context.getCurrentScenario();context.getCurrentStory();始终为空。

我所需要的只是在调用驱动程序之前获取方案名称,并在驱动程序功能中进行设置。我究竟做错了什么?也许还有另一种方法?

P.S。 serenity-jbehave 1.13.0,serenity-core 1.2.3-rc.5

1 个答案:

答案 0 :(得分:0)

您需要在配置中添加ContextStoryReporter的实例:

configuration.storyReporterBuilder().withReporters(new ContextStoryReporter(context));
相关问题