-
Notifications
You must be signed in to change notification settings - Fork 71
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
Unable to match pattern with line continuation and no further characters on second line #319
Comments
@kieran-ryan thanks! I'll look into this. |
@kieran-ryan I've looked into this, and it seems to be a correct behavior of Gherkin parser. I run the test on the official reference inplementation: Feature: foo
Scenario: bar
Given a line continuation
Then failure $ npm install --save-dev @cucumber/cucumber
$ node_modules/.bin/gherkin-javascript test.feature | jq {
"source": {
"data": "Feature: foo\n Scenario: bar\n Given a line continuation \n Then failure\n",
"uri": "test.feature",
"mediaType": "text/x.cucumber.gherkin+plain"
}
}
{
"gherkinDocument": {
"feature": {
"tags": [],
"location": {
"line": 1,
"column": 1
},
"language": "en",
"keyword": "Feature",
"name": "foo",
"description": "",
"children": [
{
"scenario": {
"id": "ff6d7cc4-677a-4f0a-9c2c-8fdff4d0aef0",
"tags": [],
"location": {
"line": 2,
"column": 3
},
"keyword": "Scenario",
"name": "bar",
"description": "",
"steps": [
{
"id": "833488c0-2611-4d0c-b567-bcf1b51d7dff",
"location": {
"line": 3,
"column": 5
},
"keyword": "Given ",
"keywordType": "Context",
"text": "a line continuation"
},
{
"id": "e186eb36-780c-4735-bc6a-17642089c1f8",
"location": {
"line": 4,
"column": 5
},
"keyword": "Then ",
"keywordType": "Outcome",
"text": "failure"
}
],
"examples": []
}
}
]
},
"comments": [],
"uri": "test.feature"
}
}
{
"pickle": {
"id": "5f22b53d-0764-4ba4-8760-19f97bddf6c0",
"uri": "test.feature",
"astNodeIds": [
"ff6d7cc4-677a-4f0a-9c2c-8fdff4d0aef0"
],
"tags": [],
"name": "bar",
"language": "en",
"steps": [
{
"id": "039d6e5f-0029-401f-86d1-a967d0aa2066",
"text": "a line continuation",
"type": "Context",
"astNodeIds": [
"833488c0-2611-4d0c-b567-bcf1b51d7dff"
]
},
{
"id": "d4e8534d-47fc-4f30-bcfd-ea9f5abe0179",
"text": "failure",
"type": "Outcome",
"astNodeIds": [
"e186eb36-780c-4735-bc6a-17642089c1f8"
]
}
]
}
} We can clearly see the trailing whitespace in the I doubt we should deviate from the official reference implementation in this detail, since Gherkin doesn't expose any concrete formal grammar. And thus, unfortunately for you, you should consider in your tests that trailing spaces are omitted. |
Super, thank you for the immediate follow-up! That validates my assumption: no gherkin step will match a step definition pattern with trailing whitespace. Thus, I would suggest a change request for Thanks for the awesome support! 🙌 |
Makes sense. Would love to see a PR. |
What did you observe?
Integrating support for line continuations in step definition patterns into the official cucumber VSCode extension (cucumber/vscode#179). Was unsure how to handle a line continuation no further characters on the following line. No error thrown, and was unable to find a matching gherkin step.
With the below example, I would have assumed the gherkin text (which includes a trailing space) would have matched the pattern.
Given a line continuation
For a working example, having a character on the second line would match as follows:
Given a line continuation !
Where are you looking for help?
Is there a gherkin step text example that matches the above pattern?
Version information
The text was updated successfully, but these errors were encountered: