gpt4 book ai didi

java - JBehave junit 测试输出分组

转载 作者:行者123 更新时间:2023-12-02 09:31:04 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com