shelholmes221
shelholmes221

Reputation: 600

Scenario Outline without examples - Cucumber

Does Scenrio outline works without Examples and just a table in every tool or Intellij is the special one?

I read the Gherkin reference and it specifies that a Scenario outline must have an Examples below it.

https://docs.cucumber.io/gherkin/reference/

But when I run my tests using Scenario Outline it works fine without the Examples section anywhere. Here:

Scenario Outline: Sequence of customer update for something
  Given we create a Customer 
  When we update the customer with a state "<name>"
      Then the response status code is 200
        And we close the response

        | name|
        | Bob|
        | Adam|
        | Rachel|

How is that working?

Upvotes: 4

Views: 4091

Answers (2)

In my case I falsely had a Scenario Outline without examples at all:

Scenario Outline: System displays search criteria
    Given UserS is logged in 
    Then UserS is on the 'Search' page
    When UserS clicks on the 'Search criteria' link
    Then the system displays the search criteria

Tests weirdly run all the way completing without errors. It was only when I tried to create an html report that a bug kept saying that examples did not exist, which led us to check the feature file.

So my guess is the tests somehow bypass the Examples section, if there is no parameter present, but the reporter is not that lenient.

Upvotes: 0

Nathaniel C
Nathaniel C

Reputation: 564

I think it's interpreting the table as a Cucumber Data Table, which looks similar to an Example table but behaves differently. Example tables cause the entire scenario to re-run for each row, but Data Tables are just a large, single parameter passed into the step immediately above them.

I am a little surprised that you didn't get a syntax error for omitting the Examples: keyword though. I just tried removing the Examples: on one of the Scenario Outlines in my environment, and while it did "pass" (or rather, didn't fail), it didn't actually run the test (the report shows 0 scenarios, 0 steps). So beware, you may have a false positive on your hands.

I went to file a bug actually, and found that it has already been filed. Ten years ago...

Upvotes: 1

Related Questions