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 examples in title #267

Closed
marcfallows opened this issue Oct 23, 2014 · 23 comments
Closed

Scenario outline with examples in title #267

marcfallows opened this issue Oct 23, 2014 · 23 comments

Comments

@marcfallows
Copy link

Hello,

I would expect to be able to have my scenario outline title have more information by using the examples within the title itself:

Scenario Outline: A <some> step is <result>
   When a <some> step
   Then I get <result>
Examples:
   | some    | result  |
   | passing | passed  |
   | failing | skipped |

Then my scenario titles end up very useful:
Scenario: A passing step is passed
Scenario: A failing step is skipped

This doesn't seem to be working for me. Is this a supported feature? If not, is it something that I could assist in having included? Or, is it not expected to work like this?

@chrismilleruk
Copy link
Contributor

+1

I had a look in some upstream projects to try figure out what the current behaviour is and therefore where this request could go. The closest behaviour is the --expand option for the cucumber formatter which appears to produce something along the following lines:

Scenario Outline: A <some> step is <result>
   When a <some> step
   Then I get <result>

Examples:
   Scenario: | passing | passed  |
      When a passing step
      Then I get passed

   Scenario: | failing | skipped |
      When a failing step
      Then I get skipped

https://github.com/cucumber/cucumber/blob/master/features/docs/gherkin/expand_option_for_outlines.feature

That said, I'm not sure where a request to change this behaviour should go. Perhaps @jbpros or @aslakhellesoy can help direct this.

@op1ekun
Copy link

op1ekun commented Oct 31, 2014

+1

@jwoudenberg
Copy link

+1, this would greaty increase the readability of scenario outline names.

@aslakhellesoy
Copy link
Contributor

I like it! +1

@aslakhellesoy
Copy link
Contributor

For the record: I don't like Scenario Outlines. They are a smell that usually means you should write unit tests instead. That's where permutation testing belongs.

@jbpros
Copy link
Member

jbpros commented Dec 21, 2014

Let me repeat it: I don't like scenario outlines either!

That being said, this is a nice suggestion within the scope of scenario outlines. Please send a PR.

@mattwynne
Copy link
Member

-1

I think gherkin documents work best if each element has a meaningful, human readable name.

Scenario outlines have a place - sometimes tabular data is the best way to illustrate behaviour - but the placeholders and substitutions are a big impediment to readability. pushing that impediment up out of the steps of the outline and into its title is too far, IMO.

@jbpros
Copy link
Member

jbpros commented Dec 21, 2014

Good point @mattwynne.

@aslakhellesoy
Copy link
Contributor

I think it's easier to discuss pros and cons of this feature with some real examples rather than toy ones.

Who can convince @mattwynne ?

chrismilleruk added a commit to chrismilleruk/cucumber-js that referenced this issue Dec 28, 2014
@chrismilleruk
Copy link
Contributor

I think this suggestion has a very strong place within the Scenario Outline feature as it exists today. Happy to create a PR for this once the behaviour is agreed.

Scenario Outlines serve to reduce repetition in gherkin documents by acting as templates for generated scenarios. While I agree that this abstraction can reduce readability in some circumstances, it can also be used to improve readability and I'm certain that it can improve maintainability.

Feature: Registration Form
Scenario Outline: Character limits.
--OR--
Feature: Registration Form
Scenario Outline: The <field> box is limited to <max> characters.

At the other end of things in test result land (and spec browser land), the value added by unique and meaningful scenario names seems too good to ignore.

Character limits.
Character limits.
Character limits.
Character limits.
Character limits.
--OR--
The username box is limited to 50 characters.
The password box is limited to 100 characters.
The confirm password box is limited to 100 characters.
The age box is limited to 3 characters.
The postcode box is limited to 10 characters.

As an aside, I think that most edit-time issues can be improved by better editors. Keyword colouring and indenting goes a long way in most languages but some sort of live preview feature can aid comprehension where templates are concerned.

The other item that deserves some consideration is what might happen if there are multiple Examples blocks. Should the example block name be incorporated in the generated scenario name somehow? Tacked on the end? Substituted with example values? Out of scope for this PR? I have never used multiple example blocks so I don't think I'm in a position to comment.

@lenient
Copy link

lenient commented Dec 30, 2014

When this feature will be released?
In fact, I just copy the source code in my local to use it ^^

@aslakhellesoy
Copy link
Contributor

I just realised Cucumber-JVM already does this. I can't remember if I implemented that myself or if it was someone else. Thanks for the heads up @brasmusson !

@chrismilleruk
Copy link
Contributor

Thanks @aslakhellesoy,

I've sent a PR across, let me know if you need any alterations.

@sejtan88
Copy link

sejtan88 commented Jan 5, 2015

This feature will help me very much. Any ETA when this will be released? I have copied source code and it is working fine, but it would be good to have it in npm install.

@chrismilleruk
Copy link
Contributor

Hi, just a gentle nudge to @jbpros, @mattwynne and @aslakhellesoy on this.

It would be great if we could get some feedback on the PR.

Thanks
Chris

@mattwynne
Copy link
Member

If this behaviour is already in Cucumber-JVM, and people want it here, I'm not going to stand it it's way. Merge on!

Don't expect me to rush to implement it in Ruby though 😀

@jbpros
Copy link
Member

jbpros commented Feb 6, 2015

@chrismilleruk can you rebase off master please?

chrismilleruk added a commit to chrismilleruk/cucumber-js that referenced this issue Feb 6, 2015
@chrismilleruk
Copy link
Contributor

@jbpros all done.

I've left it as two commits since it's easier to diff that way. Let me know if you'd like me to squash it.

@chrismilleruk
Copy link
Contributor

Hi @jbpros,

Just checking in to see if there's anything I can do to assist further here.

@riaan53
Copy link

riaan53 commented May 28, 2015

Awesome!

Can we get a merge for PR: #291 please :)

Thank you @chrismilleruk and the rest!

@jbpros
Copy link
Member

jbpros commented Jun 12, 2015

Closed by 4673a59.

@JimLynchCodes
Copy link

I'm with @mattwyne. Scenario Outlines are great. They allow you to separate the business logic of the test from the individual equivalence partition values, and it's easier for people who didn't write the scenarios to edit the data values later on.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests