2

I'm trying to create a scenario where two users would access the application, so I could simulate a sold-out product when one user has it on the cart (more or less).

E.g.

Given user1 access website
Then user1 add a product to the cart

Here comes the user2 (not quite sure if I should use another Given or an And, the point here would be opening another window, and keep the window from user1 on hold).

Given user2 access website
Then user2 add a product to the cart
And user2 complete purchase (Closing the window of user2)

Here the user1 would try to finish the purchase (back to user1 window)

Then user1 tries to finalize the purchase and gets a warning that product is no longer available

That is more of an idea than the actual flow, but the main point here is to have this "conflict" of empty inventory. I want the user1 to be able to add the product to the cart to later display a warning that the product is no longer available. So, I can't have the Scenario starting with an empty inventory because then the user1 won't even see the product to test against it.

Mate Mrše
  • 6,305
  • 6
  • 26
  • 53

2 Answers2

1

I suggest to use following linear approach. I assume that it is possible to log 2 users at one browser in different tab's

Given user1 access website
When user1 add a product to the cart
And I open 2nd chrome tab
And user2 access website on 2nd tab
And user2 add a product to the cart
And user2 complete purchase
And I close 2nd chrome tab
And I refresh session on 1st tab
Then user1 can not complete purchase and and see 'product no longer available' warn
WKOW
  • 306
  • 1
  • 6
1

I suggest to use reader-friendly definitions and emphasize the action that lead to your expected result with When clause

Given One item of "ShortProduct" is available 
   And the following users are registered
    | User Name      |
    | James Luckless |
    | John  Lucky    |
   And "James Luckless" added a "ShortProduct" to the cart
   And "John  Lucky" added a "ShortProduct" to the cart
   And "John  Lucky" completed the purchase
When "James Luckless" attempts to finalize the purchase 
Then "James Luckless" gets a warning that "ShortProduct" is no longer available