我正在尝试使用Serenity和Cucumber编写可执行规范。
我希望在带有示例的方案的每个示例之前重置阶段。在这里,当运行第二个示例时,第一个示例将操作它的结果,在这种情况下,它期望列表显示Buy some water
,而实际列表同时包含Buy some milk
和Buy some water
我正在黄瓜4中写黄瓜规格。
sample.feature
Scenario Outline: Viewing the items by status
Given that Jane has a todo list having
| <task1> | <task2> |
And she has completed the task called
| <select> |
When she filters her list to show only <filter> tasks
Then her todo list should contain
| <expected> |
Examples:
| task1 | task2 | select |filter | expected |
| Buy some milk | Walk the dog | Buy some milk | Active | Walk the dog |
| Buy some water | Walk the cat | Buy some water | Completed | Buy some water |
SampleStepDefinition.java
@Before
public void set_the_stage() {
OnStage.setTheStage(new OnlineCast());
}
@Then("his/her/the todo list should contain")
public void todo_list_should_contain(List<String> expectedItems) throws Throwable {
theActorInTheSpotlight().should(seeThat(TheItems.displayed(), equalTo(expectedItems))
.orComplainWith(MissingTodoItemsException.class, "Missing todos expected:" + expectedItems ));
}