1

I have a scenario where I need to insert some data in the system and after that, I check if that data was inserted correctly. Something like:

Given the user in the insertion screen

When he inserts the products

| Code | Name      | Price |
| 001  | Product 1 | 1,00  |
| 002  | Product 2 | 1,50  |
| 003  | Product 3 | 2,00  |

Then he checks if the products were inserted correctly

| Code | Name      | Price |
| 001  | Product 1 | 1,00  |
| 002  | Product 2 | 1,50  |
| 003  | Product 3 | 2,00  |

I use the same table twice to check if it is indeed the same. I'd like to know if there's a way to make it one single table for both when and then.

3

You can use Scenario Outlines.

Scenario Outline: Insert and Verify data blah blah
Given I insert <code>, <name> and <Price> into database
Then I can verify that <code>,<name> and <price> has been inserted 
successfully
Examples:
| Code | Name      | Price |
| 001  | Product 1 | 1,00  |
| 002  | Product 2 | 1,50  |
| 003  | Product 3 | 2,00  |
  • I can't because I need to insert all the table data once and then check it. Not one per time as Scenario Outline does. – Mateus Lemes Feb 28 at 12:11
  • Then you need to write two scenarios or two stories/features. I can't think of any reason why validating after all data is entered is any better than validating data AS it's entered, but if that's what your client wants, write two scenarios/stories. Then bill them for twice the work. – Bill Hileman Mar 1 at 18:37
2

You could do something like this (using almost the above answer example)

Scenario: Insert and Verify data blah blah
Given I insert the following items into some form
  | Code | Name      | Price |
  | 001  | Product 1 | 1,00  |
  | 002  | Product 2 | 1,50  |
  | 003  | Product 3 | 2,00  |
Then the items should appear on the list

At the Given step you perform interactions to insert the items and save them in a variable to use later on the Then step to check existance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.