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

Feature/Scenario description can only be 1 line #10

Closed
incident-recipient opened this issue May 1, 2020 · 15 comments
Closed

Feature/Scenario description can only be 1 line #10

incident-recipient opened this issue May 1, 2020 · 15 comments
Labels
bug Something isn't working
Milestone

Comments

@incident-recipient
Copy link
Contributor

One of the primary benefits of BDD is that it produces living documentation. This can be particularly effective when the gherkin is post-processed by something like AsciiDoctor to provide URLs, images, mathematical notation, etc in a convenient, easy to read and useful document.

However, unlike other parsers this one appears to crash if the descriptions for Features/Scenarios are more than one line long or have any whitespace

Steps to reproduce-> Use the following Gherkin
Feature: Living Documentation
Living documentation is used by may companies, including those with mission critical objectives such as healthcare. In these cases, the documentation is the source of truth and is central to the businesses operations.

Not being able to document or provide mark up or other useful features limits the viability of what is supposed to be a source of truth.

Scenario: Adequate Description for core operations.
We definitely want to be able to do this.

Given I am writing living documentation
And many levels of management, coworkers and others rely on it
Then I need to have lengthier descriptions for features and scenarios

@bbqsrc bbqsrc added the bug Something isn't working label May 1, 2020
@bbqsrc
Copy link
Member

bbqsrc commented Sep 7, 2020

This should now be fixed.

@bbqsrc bbqsrc closed this as completed Sep 8, 2020
@incident-recipient
Copy link
Contributor Author

This does not appear to be fixed. I was able to duplicate the issue by adding a multiline scenario to the test in the src code as well as existing rust projects now using the latest library.

Feature: Everything

Scenario: Nothing
Given I just started

Scenario: Multiline
Adding a multiline scenario when using the Feature files as input to generate documentation.

            There can be a lot of arbitary text and newlines but it shouldn't matter as long as one of the sentences doesn't start with a Gherkin keyword.
            Given I just started

@incident-recipient
Copy link
Contributor Author

The issue seems to be with this rule in the new parser:
rule scenario() -> Scenario
= _
t:tags()
_
pa:position!()
keyword((env.keywords().scenario)) ":" _ n:not_nl() _ nl_eof() //Stop when we encounter a new line
s:steps()?

My employer limits what I can contribute to open source projects. I'll see what I can do to help though.

@bbqsrc bbqsrc reopened this Sep 18, 2020
@bbqsrc
Copy link
Member

bbqsrc commented Sep 18, 2020

Ah, I misunderstood the issue. I'll look into it when I have time, unless somebody else does it first.

@bbqsrc bbqsrc added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 18, 2020
@incident-recipient
Copy link
Contributor Author

Unfortunately I wasn't given clearance to contribute (not that I'm particularly proficient at rust yet anyway).

But I think the solution will be along the answers of making a rule that says "newline followed by any whitespace followed by one of the 3 main gherkin keywords":

rule test_case_start() -> &'input str = n: $(nl() _ (env.keywords().given() / env.keywords().when() / env.keywords().then)) { n }
...
...
rule scenario() -> Scenario = ....
....
keyword((env.keywords().scenario)) ":" _ n: !test_case_start()+

The above won't compile, but it can hopefully steer someone in the correct direction.

@bbqsrc
Copy link
Member

bbqsrc commented Jan 26, 2021

Fixed in v0.8.4.

@bbqsrc bbqsrc closed this as completed Jan 26, 2021
@bbqsrc
Copy link
Member

bbqsrc commented Jan 29, 2021

0.8.4 was yanked due to causing other parsing issues.

@bbqsrc bbqsrc reopened this Jan 29, 2021
@bbqsrc
Copy link
Member

bbqsrc commented Jan 30, 2021

This is fixed in 0.9.0. Arbitrary descriptions below scenarios are not supported by the specification, and so are not included.

@bbqsrc bbqsrc closed this as completed Jan 30, 2021
@incident-recipient
Copy link
Contributor Author

It isn't obvious, but gherkin does support multi-line scenarios.

Here is a multi-line test case out of the official mono-repository, which has been used to test other language implementations:
https://github.com/cucumber/cucumber/blob/master/gherkin/testdata/good/descriptions.feature

I think it would perhaps be worthwhile to move these official test cases to cucumber-rust/gherkin-rust as they would serve as a source of truth on how cucumber should behave (which ultimately is the point of the feature files anyway).

@bbqsrc
Copy link
Member

bbqsrc commented Jan 30, 2021

Of course there's tests for something described absolutely nowhere.

Supporting cucumber is seriously painful, haha.

@bbqsrc bbqsrc reopened this Jan 30, 2021
@tyranron
Copy link
Member

tyranron commented Dec 8, 2021

@ilslv is it still relevant?

@ilslv
Copy link
Member

ilslv commented Dec 9, 2021

@tyranron yes, as only Features are allowed to have multi-line descriptions, while Scenarios doesn't even have description field yet.

@tyranron
Copy link
Member

@ilslv is this fully fixed by #32 now?

@tyranron tyranron removed help wanted Extra attention is needed good first issue Good for newcomers labels Mar 28, 2022
@ilslv
Copy link
Member

ilslv commented Mar 28, 2022

@tyranron yes, this issue should be fully covered.

tyranron pushed a commit that referenced this issue Mar 28, 2022
- add `description` field to `Background`, `Examples`, `Rule` and `Scenario` (#10)
- make `name` field of `Background` required
- make `table` field of `Examples` optional

Co-authored-by: ilslv <[email protected]>
@tyranron tyranron added this to the 0.12.0 milestone Mar 28, 2022
@tyranron
Copy link
Member

Released in gherkin 0.12.0 and cucumber 0.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants