These are chat archives for Behat/Behat

10th
Nov 2017
Admiral Husker
@admiral_husker_twitter
Nov 10 2017 12:18

Hi everyone,

I am wondering how i could test a multi-users validation workflow without putting away the context readability provided by Background.

The workflow is the following :

  1. A user "A" can create a request
  2. Then user "B" and only him can validate the request
  3. Then user "C" and only him can validate the request
  4. Then user "A" is notified that his request is validated

I init the context with Background step and tables to see the context just by looking at the feature file.

But Background is hooked before scenario, not before the feature starts, so i can't test this workflow with multiples scenarios and Background because it keeps scenarios isolated from each others :

Scenario: User "A" can create a request
    Given I am logged as "A"
        And I follow "Create a new request"
    When I press "Create"
    Then I should see "New request created"

Scenario: User "C" cannot validate the request yet
    Given I am logged as "C"
    When I follow "View requests"
    Then I should not see request from "A"

Scenario: User "B" can validate the request once
    Given I am logged as "B"
    When I validate request from "A"
    Then I should see "Request from A validated"
        And I should not see request from "A"

Scenario: User "C" can validate the request once
    Given I am logged as "C"
    When I validate request from "A"
    Then I should see "Request from A validated"
        And I should not see request from "A"

Scenario: User "A" is notified of validation
    Given I am logged as "A"
    When I follow "Show messages"
    Then I should see "Your request has been validated"

How would you handle this ? Without using Background ? All this steps inside one scenario ?