Cucumber-Serenity - Как выполнить код перед каждым примером наброска сценария, написанного на Cucumber - PullRequest
0 голосов
/ 11 ноября 2019

Я пытаюсь написать исполняемые спецификации, используя Serenity и Cucumber.

Я бы хотел, чтобы этап сбрасывался перед каждым примером сценария с примерами. Здесь, когда serenity запускает второй пример, первый пример манипулирует его результатом, и в этом случае он ожидает, что список покажет 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 ));
    }

...