Reputation: 4136
I have four very similar sections on my application and am trying to group tests together that are similar enough using scenario outline to facilitate maintenance and am giving the section (page) they're to be under as a parameter. However, these tests when written individually contain a different amount of items under their datatable (but still doing the same assertions), so I was wondering if it's possible to have a different databable for each examples sections?
Something like:
Scenario Outline: Verify that the user is able to see the details recorded on the note
And I navigate to the "<page>" screen
Then the following items are displayed for their respective fields
@page1
Examples:
Then the following items are displayed for their respective fields
| field | text |
| title | My title |
| history | My history |
@page2
Then the following items are displayed for their respective fields
| field | text |
| comment | My comment |
| details | My details |
| status | My status |
Note I'm omitting the page parameter as not sure where it should go, as if doing something like the below would mean they would be run multiple times within each example
@page1
Examples:
Then the following items are displayed for their respective fields
| page | field | text |
| page1 | title | My title |
| page1 | history | My history |
I also can't have something like:
Scenario Outline: Verify that the user is able to see the details recorded on the note
Then the following items are displayed for their respective fields
@page1
Examples:
Then the following items are displayed for their respective fields
| field | text | item1 | item2 |
Because these amounts change, so I could have three items under the test for a page but two items on another one and maybe four on the other one.
I hope I'm being clear enough on what I'm trying to achieve?
Many thanks.
Upvotes: 2
Views: 1065
Reputation: 12019
You're writing your scenarios very much like a test script where you describe each step. This doesn't work with Gherkin. It is not a programming language and trying to program in it is hard. Try to write down the behavior of the application instead.
Scenario: Details of the note can be seen on page1 and page2
Given Claire has created a note
| property | value |
| title | My title |
| ect ....
When she views the notes details
Then on "Notes Overview" she can see:
| field | text |
| title | My title |
| history | My history |
And on "Note Details" she can see:
| field | text |
| comment | My comment |
| details | My details |
| status | My status |
In the Given
step you create a user named Claire, open the app, and create the note. In the When
step you navigate to the right page and in the Then
steps you check if the right things are visible in the right fields.
Upvotes: 2