rlogiacco / Natural

Natural is a collection of Eclipse plugins to enable rich smart editing of acceptance tests using natural language definition files. It currently supports Cucumber and JBehave syntax.
Eclipse Public License 1.0
75 stars 37 forks source link

Update to Gherkin 3 #43

Open hsudbrock opened 9 years ago

hsudbrock commented 9 years ago

In the following example, I get java hyperlinks for the second line in the scenario outline, but not for the first. It seems to be caused by using '*' and not one of the keywords 'And', 'Given', etc.

Feature: Checkout

    Scenario Outline: Checkout a banana
        * the price of a "banana" is 40c
        And the price of a "pear" is 60 c
        When I checkout <count> "banana"
        And I checkout 1 "banana"
        And I checkout 2 "pear"
        Then the total price should be <total>c

        Examples:
        | count | total |
        | 1     | 200   |
        | 2     | 240   |
        | 3     | 280   |

missing-java-link

rlogiacco commented 9 years ago

Your interpretation is correct, actually the line starting with the asterisk is not interpreted as a step but it is rather considered part of the scenario outline description. I wasn't aware the asterisk can be used to identify a step: can you point me to the documentation regarding this?

hsudbrock commented 9 years ago

Interesting - Cucumber happily executes my Gherkin features that contain the asterisk, but I cannnot find it documented in the Cucumber documentation.

I know the asterisk-feature from this book: https://pragprog.com/book/srjcuc/the-cucumber-for-java-book. The asterisk-feature is also described in blog entries on Cucumber (e.g., http://antonymarcano.com/blog/tag/gherkin/).

Nevertheless, the asterisk-feature is not documented in the attempt to define a BNF grammar for Gherkin (https://github.com/cucumber/gherkin/wiki/BNF).

I will try to find out where these asterisks are handled in Cucumber's Gherkin parser...

rlogiacco commented 9 years ago

Sadly the Natural plugin doesn't use the Gherkin parser, but one I've described myself in an EBNF like syntax. If you wish I'm still strugglying to find a way to use the official parser and get rid of the many parsing issues we are experiencing.

Would you be willing to help me on this?

hsudbrock commented 9 years ago

In the Gherkin3 parser project the asterisk is defined in the language definition file (https://github.com/cucumber/gherkin3/blob/master/gherkin-languages.json), where the asterisk is just one of potentially multiple "translations" for keywords like "when", "given", etc. It seems odd to me defining the asterisk as a translation, but the Gherkin3-people will have had a good reason for that, I guess.

Yes, I would be willing to help, but cannot say yet when I will find time for this. I'll keep in touch.

drkstr101 commented 4 years ago

Updated URL: https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json

This will most likely need to be included in a general "localization" update. The issue is in fact that newer versions of Gherkin will match practically any starting word as a keyword. I have even seen joke implementations written in Klingon. We will probably need to update the AST to use any keyword as the starting word, or just ignore it altogether and consume the whole line of text as the step. This would actually solve another problem I'm running into with the code generator, which is the lack of support in the AST to access the keyword, preventing serialization until an update can be made. It will also make step matching a bit more expensive, but this can be mitigated in other ways.

drkstr101 commented 4 years ago

@rlogiacco Confirmed partial fix in next. * is now a supported Step keyword. There have also been other minor improvements on the localization front, but nothing to fruition yet.

github-actions[bot] commented 4 years ago

This issue has not been updated for a while: marking it as stale.

drkstr101 commented 4 years ago

@rlogiacco This will be closed by https://github.com/rlogiacco/Natural/pull/86