Then's in assert something that confirms or rejects the behaviour that has been exercised by the When. So examine the When to determine the Then. In your example your when isn’t very clear and comprises of many steps which is perhaps why you are having some issues. Lets simplify your When and then look at the Then.

When I buy some products
Then I have bought some products

When I add some products to my basket
Then I should have some products in my basket

When I pay for my items
Then I should have paid for my items

When I foo
Then I should have foo'd

All of these follow the same pattern and have some common characteristics

  1. A single When matching a single Then
  2. All are happy path we are not dealing with errors
  3. All define a name for something that is important to your business context
  4. None of them have anything to do with HOW you do something

The art of Cucumber is to use your control of natural language and your understanding of your business context to create scenarios that fit this pattern and communicate effectively. If you do this then you get a great deal of help in driving the development of each piece of behaviour that you have define in you When.

After you have your basic behaviour defined then you can use additional scenarios to explore sad paths.

The scope of your scenario ends when you have proof that your When is complete. In your example things like ‘leaving the shop’ and ‘walking to the car’ are irrelevant. They don’t confirm anything to do with buying products.

Perhaps you are thinking that because your Givens mention them then your Thens should too. This is wrong Thens are only interested in Whens.



Source link https://sqa.stackexchange.com/questions/34698/where-will-the-cucumber-then-

LEAVE A REPLY

Please enter your comment!
Please enter your name here