Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario Outline with multiple examples dosent work #1082

Open
cherifGsoul opened this issue Sep 25, 2017 · 11 comments
Open

Scenario Outline with multiple examples dosent work #1082

cherifGsoul opened this issue Sep 25, 2017 · 11 comments

Comments

@cherifGsoul
Copy link

cherifGsoul commented Sep 25, 2017

I want to use Scenario Outline with multiple examples table but it runs the last examples table only, here is an example

Feature: testing scenarios with multiple examples section
        Scenario Outline: outline
          When a table step:
            | first   | second   |
            | <first> | <second> |

        Examples: First set of examples
          | first   | second  |
          | 1       | 2       |

        Examples: Second set of examples
          | first   | second  |
          | 3       | 4       |
          | 5       | 6       |

this example is taken from cucumber issue cucumber/cucumber-js#217 where it had the same issue and it was considered as a bug.

@jon-acker
Copy link

jon-acker commented Sep 25, 2017 via email

@cherifGsoul
Copy link
Author

cherifGsoul commented Sep 25, 2017

I have multiple scenarios to check and they share contexts/actions the examples above dosent demonstrate the benefit, for example I design a cms so I want to check when I define a new content types which dont exist (valid scenario) and the second examples to define content types which already exists (invalid scenario), they can be in the same table (examples) but I consider this multiple scenarios in one.
Examples are Scenarios, right?

@jon-acker
Copy link

jon-acker commented Sep 25, 2017 via email

@cherifGsoul
Copy link
Author

@jon-acker After the issue submission I refactored the scenarios to be like you said, thank you :)

@phil-davis
Copy link
Contributor

phil-davis commented Nov 3, 2017

For readers of a scenario outline there is a case for being able to make multiple example tables. Then you can head them up with descriptions of their purpose, e.g.

    Examples: of ordinary Latin character inputs

    Examples: of Unicode inputs

    Examples: of invalid inputs

    Examples: of weird edge cases for XYZ

that makes it easier for others to understand the purpose of subsets of examples.

And if/when it becomes supported to tag scenario outline examples, you could also be able to tag each examples table.

That way, there is the potential to run different combinations of example tables on a test run. e.g. have examples tables of "a few typical valid inputs" and "a few typical invalid inputs" and tag those "smoketest". Then you can run --tag smoketest with every pull request, and have it finish in a finite amount of time. A less-frequent job can be scheduled to run everything, processing all examples tables including ones that have lists of wacky edge cases...

@phil-davis
Copy link
Contributor

For the record, the current behavior is that the last examples table is run, e.g.:

	Background:
		Given a regular user exists
		And I am logged in as a regular user
		And I am on the files page

	Scenario Outline: Rename a file using special characters
		When I rename the file "lorem.txt" to <to_file_name>
		Then the file <to_file_name> should be listed
		And the files page is reloaded
		Then the file <to_file_name> should be listed

		Examples:
		|to_file_name |
		|'ordinary-name.txt' |
		|'MixedCaseName.txt' |
		Examples:
		|to_file_name |
		|'"quotes1"'  |
		|"'quotes2'"  |
		Examples:
		|to_file_name |
		|'लोरेम.txt'  |
		|'strängé name.txt'  |

runs 2 scenarios for the 2 file names in the last examples table.
The other examples tables are ignored - I guess the parser sees them as free text between the Scenario Outline steps and that last Examples table.

@danchukas
Copy link

I fixed it in fork danchukas/Behat.
I hope this fix and another features apllied to original Behat.
#1101

@everzet
Copy link
Member

everzet commented Nov 20, 2017

This might have a deep-cutting implications on formatters, so I'd look into this one for next major.

@cherifGsoul
Copy link
Author

@everzet Thank you!

@ghost
Copy link

ghost commented Oct 2, 2019

Any update as to when this will be part of the next behat release?

@tkotosz
Copy link
Contributor

tkotosz commented Nov 26, 2019

I would love to see this feature introduced so just linking the related Gherkin issue and MR here so it easier to find it.
Related Gherkin repo issue: Behat/Gherkin#117
Related Gherkin repo PR (closed): Behat/Gherkin#119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants