目前我正在尝试使用 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 如下。
我只想按场景对输出进行分类
最佳答案
关于java - JBehave junit 测试输出分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57974236/