Search code examples
cucumbercuke4duke

Is it possible to use 2 different examples table in Cucumber/Cuke4Duke


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.


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 |