【问题标题】:JBehave junit test output groupingJBehave junit测试输出分组
【发布时间】:2019-09-17 12:29:01
【问题描述】:

目前我正在尝试使用 JBehave 做一些 BDD 并使用“JUnitStory”,如下所示。

import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.junit.JUnitStory;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;

public class MyStory extends JUnitStory {
    @Override
    public Configuration configuration() {

        return new MostUsefulConfiguration()
                .useStoryLoader(new MyStoryLoader("src\\main\\resources\\hello.story"));
    }

    @Override
    public InjectableStepsFactory stepsFactory() {
        return new InstanceStepsFactory(configuration(), new MySteps());
    }
}

我的问题是甚至我的步骤文件包含多个场景,junit 输出未按场景分组。你能告诉我怎么做吗?

我的步骤文件如下

Narrative:
  In order to find items that I would like to purchase
  As a potential buyer
  I want to be able to search for items containing certain words

Scenario: Should list items related to a specified keyword
Given The "XXXX" is initiated as
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|
When The "YYYY" submission is invoked as
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|
Then The "ZZZZ" should be
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|

Scenario: Should be able to filter search results by item type
Given The "XXXX" is initiated as
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|
When The "YYYY" submission is invoked as
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|
Then The "ZZZZ" should be
|Description|Value|Matcher|Verified|
|Value1|Value1|"Value1"|Yes|
|Value2|Value2|"ValueX"|No|

当前结果窗格如下。

我只想按场景对输出进行分类

【问题讨论】:

    标签: java bdd jbehave


    【解决方案1】:

    为此目的使用 JBehave JUnit 运行器:https://github.com/valfirst/jbehave-junit-runner

    输出示例:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 2010-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多