Question

Is it possible to somehow construct a Scenario which uses two different Example tables in different steps? Something like this:

Given I log in
When I view a page
Then I should see <goodText>
Examples:
|goodText|
|abc|
And I should not see <badText>
Examples:
|badText|
|xyz|

The scenario above doesn't work, also in reality there would be more rows to each table.

Was it helpful?

Solution

It looks like you're confusing tables with scenario examples. You can mix them, but from your example I'm not sure what you're trying to achieve. Why not just write:

Given I log in
When I view a page
Then I should see "abc"
But I should not see "xyz"

or if you wanted to check for multiple strings:

Given I log in
When I view a page
Then I should see the following text:
  | abc |
  | def |
But I should not see the following text:
  | xyz |
  | uvw |

OTHER TIPS

You say that in reality there would be many more rows to the table; but of course a table can also have many columns.

Would this not work for you?

Given I log in
When I view a page
Then I should see <goodText>
But I should not see <badText>
Examples:
|goodText| badText |
|abc     | xyz     |
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top