java - JBehave junit 测试输出分组

标签 java bdd jbehave

目前我正在尝试使用 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|

当前结果 Pane 如下。

enter image description here

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

最佳答案

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

输出示例:

JBeahve Junit output example

关于java - JBehave junit 测试输出分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57974236/

相关文章:

java - android studio 使Scrollview不可滚动

java - 将字符串转换为 double[][] - Java

java - 不兼容的类型 - 在 java 中找到了 java.lang.String 但预期为 int

java - 无法在 Eclipse 中的 Jbehave 中运行故事。需要逐步设置在 Eclipse 中使用 Jbehave 和所需的 Jars 详细信息

java - 场景通过或失败时的 Cucumber-jvm Hook

java - 如何在 Gradle 中运行单个 Serenity 测试运行器类(在几个中)?

java - 无法导入带有 type 标签的 Maven 依赖项

java - 在 Maven 中运行时,如何让 JBehave 包含测试依赖 jar?

java - 如何将最新的Groovy(2.4)与最新的Netbeans(8.2)集成?

symfony - 在我的 Behat 场景中传递强制参数