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

format: add support for gherkin rule/example syntax #1273

Merged
merged 42 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
98144db
add basic feature for gherkin rule/example support
davidjgoss Dec 18, 2019
abf231a
use require instead of import
davidjgoss Dec 30, 2019
0667c1c
assert on formatter output for passing example
davidjgoss Dec 30, 2019
6b6e358
add formatters.feature scenario for rejected pickle from rule
davidjgoss Dec 30, 2019
71b9f9c
add formatters.feature scenario for passed from rule
davidjgoss Dec 30, 2019
9d95da3
add editorconfig for indentation control
davidjgoss Jan 1, 2020
f16beb8
formatting
davidjgoss Jan 1, 2020
3fd434d
make `getGherkinStepMap` rule-aware
davidjgoss Jan 1, 2020
6803785
restructure tests a bit
davidjgoss Jan 1, 2020
e792139
refactor tests a bit more, add some to cover getGherkinScenarioMap
davidjgoss Jan 1, 2020
76dc3dd
account for Rule in getGherkinScenarioMap
davidjgoss Jan 1, 2020
b409242
rework getGherkinScenarioLocationMap to handle Rule
davidjgoss Jan 1, 2020
df5478c
add unit test for Rule/Example in json formatter
davidjgoss Jan 1, 2020
46ecf05
report keyword as Scenario or Example correctly from scenario map
davidjgoss Jan 1, 2020
3a654fe
include rule name in concatenated scenario id for json formatter
davidjgoss Jan 1, 2020
79c1de7
make sure we work with a background within a rule
davidjgoss Jan 4, 2020
587af39
readability
davidjgoss Jan 4, 2020
1cbe83d
add background usage to rule feature, assert on failure output
davidjgoss Jan 4, 2020
8428a77
add acceptance test for message and json format on failure from rule
davidjgoss Jan 29, 2020
b8fd4eb
add a bit of coverage for the progress bar formatter
davidjgoss Jan 29, 2020
431d883
more on progress far - numbers/time reporting at end
davidjgoss Jan 29, 2020
b18d1a5
work rule usage into progress formatter spec
davidjgoss Jan 29, 2020
7e578bd
work rule usage into rerun formatter spec
davidjgoss Jan 29, 2020
de762ea
work rule usage into summary formatter spec
davidjgoss Jan 29, 2020
4e70e74
add coverage for pickle filtering on name
davidjgoss Jan 29, 2020
38dcdd6
changelog update
davidjgoss Jan 29, 2020
733b2a0
rework progress formatter spec to have a seperate case for rule/example
davidjgoss Feb 14, 2020
c66d7c3
remove negative test for rule/example in json formatter
davidjgoss Feb 14, 2020
d486330
rework gherkin document parser spec to avoid replication of structure
davidjgoss Feb 15, 2020
7ab8a0f
merge from master
davidjgoss Mar 14, 2020
c5a08fd
fix some lint
davidjgoss Mar 14, 2020
672647b
fix line numbers in formatter unit tests
davidjgoss Mar 14, 2020
b3f5afa
Merge branch 'master' into rule-example-support
davidjgoss Mar 17, 2020
9279c86
fix dodgy import
davidjgoss Mar 17, 2020
a161eba
fix overqualified references to messages interfaces
davidjgoss Mar 17, 2020
733f8f9
remove unnecessary tags
davidjgoss Mar 17, 2020
3bdc7d7
for progress bar formatter, break out new test for rule/example, reta…
davidjgoss Mar 17, 2020
beb1d57
split out new test for rule/example in rerun formatter spec
davidjgoss Mar 17, 2020
9f7f7c4
remove superfluous formatter tests
davidjgoss Mar 17, 2020
61e6c31
fix up changelog
davidjgoss Mar 17, 2020
cea78fc
fix whitespace
davidjgoss Mar 18, 2020
d8c3723
restore original names where qualifiers no longer needed
davidjgoss Mar 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# 4 space indentation
[*]
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO

### [Unreleased](https://github.com/cucumber/cucumber-js/compare/v6.0.5...master) (In Git)

* format: add support for gherkin rule/example syntax

### [6.0.5](https://github.com/cucumber/cucumber-js/compare/v6.0.4...v6.0.5) (2019-11-13)

#### Bug fixes
Expand Down
32 changes: 32 additions & 0 deletions features/background.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,35 @@ Feature: Background
| IDENTIFIER |
| Given a background step |
| When another scenario step |

Scenario: Two examples within a rule with a background, plus a feature-level background
Given a file named "features/background.feature" with:
"""
Feature: a feature
Background:
Given a feature-level background step

Rule: a rule
Background:
Given a rule-level background step

Example: first example
When an example step

Example: second example
When an example step
When another example step
"""
When I run cucumber-js
Then it fails
And the scenario "first example" has the steps:
| IDENTIFIER |
| Given a feature-level background step |
| Given a rule-level background step |
| When an example step |
And the scenario "second example" has the steps:
| IDENTIFIER |
| Given a feature-level background step |
| Given a rule-level background step |
| When an example step |
| When another example step |
147 changes: 147 additions & 0 deletions features/fixtures/formatters/failed-rule.message.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
module.exports = [
{
source: {
uri: 'features/a.feature',
data:
'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
media: {
encoding: 'UTF8',
contentType: 'text/x.cucumber.gherkin+plain',
},
},
},
{
gherkinDocument: {
uri: 'features/a.feature',
feature: {
location: {
line: 1,
column: 1,
},
language: 'en',
keyword: 'Feature',
name: 'a feature',
children: [
{
rule: {
location: {
line: 2,
column: 3,
},
keyword: 'Rule',
name: 'a rule',
children: [
{
scenario: {
location: {
line: 3,
column: 5,
},
keyword: 'Example',
name: 'an example',
steps: [
{
location: {
line: 4,
column: 7,
},
keyword: 'Given ',
text: 'a step',
id: '1',
},
],
id: '2',
},
},
],
},
},
],
},
},
},
{
pickle: {
id: '4',
uri: 'features/a.feature',
name: 'an example',
language: 'en',
steps: [
{
text: 'a step',
id: '3',
astNodeIds: ['1'],
},
],
astNodeIds: ['2'],
},
},
{
pickleAccepted: {
pickleId: '4',
},
},
{
testRunStarted: {},
},
{
testCase: {
id: '5',
pickleId: '4',
testSteps: [
{
id: '6',
pickleStepId: '3',
stepDefinitionIds: ['0'],
},
],
},
},
{
testCaseStarted: {
attempt: 0,
testCaseId: '5',
id: '7',
},
},
{
testStepStarted: {
testStepId: '6',
testCaseStartedId: '7',
},
},
{
testStepFinished: {
testResult: {
status: 'FAILED',
message:
'Error: my error\n at World.<anonymous> (features/step_definitions/steps.js:3:49)',
duration: {
seconds: '0',
nanos: 0,
},
},
testStepId: '6',
testCaseStartedId: '7',
},
},
{
testCaseFinished: {
testResult: {
status: 'FAILED',
message:
'Error: my error\n at World.<anonymous> (features/step_definitions/steps.js:3:49)',
duration: {
seconds: '0',
nanos: 0,
},
},
testCaseStartedId: '7',
},
},
{
testRunFinished: {
success: false,
},
},
]
37 changes: 37 additions & 0 deletions features/fixtures/formatters/passed-rule.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = [
{
description: '',
elements: [
{
description: '',
id: 'a-feature;a-rule;an-example',
keyword: 'Example',
line: 3,
name: 'an example',
steps: [
{
arguments: [],
keyword: 'Given ',
line: 4,
match: {
location: 'features/step_definitions/steps.js:3',
},
name: 'a step',
result: {
duration: 0,
status: 'passed',
},
},
],
tags: [],
type: 'scenario',
},
],
id: 'a-feature',
keyword: 'Feature',
line: 1,
name: 'a feature',
tags: [],
uri: 'features/a.feature',
},
]
143 changes: 143 additions & 0 deletions features/fixtures/formatters/passed-rule.message.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
module.exports = [
{
source: {
uri: 'features/a.feature',
data:
'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
media: {
encoding: 'UTF8',
contentType: 'text/x.cucumber.gherkin+plain',
},
},
},
{
gherkinDocument: {
uri: 'features/a.feature',
feature: {
location: {
line: 1,
column: 1,
},
language: 'en',
keyword: 'Feature',
name: 'a feature',
children: [
{
rule: {
location: {
line: 2,
column: 3,
},
keyword: 'Rule',
name: 'a rule',
children: [
{
scenario: {
location: {
line: 3,
column: 5,
},
keyword: 'Example',
name: 'an example',
steps: [
{
location: {
line: 4,
column: 7,
},
keyword: 'Given ',
text: 'a step',
id: '1',
},
],
id: '2',
},
},
],
},
},
],
},
},
},
{
pickle: {
id: '4',
uri: 'features/a.feature',
name: 'an example',
language: 'en',
steps: [
{
text: 'a step',
id: '3',
astNodeIds: ['1'],
},
],
astNodeIds: ['2'],
},
},
{
pickleAccepted: {
pickleId: '4',
},
},
{
testRunStarted: {},
},
{
testCase: {
id: '5',
pickleId: '4',
testSteps: [
{
id: '6',
pickleStepId: '3',
stepDefinitionIds: ['0'],
},
],
},
},
{
testCaseStarted: {
attempt: 0,
testCaseId: '5',
id: '7',
},
},
{
testStepStarted: {
testStepId: '6',
testCaseStartedId: '7',
},
},
{
testStepFinished: {
testResult: {
status: 'PASSED',
duration: {
seconds: '0',
nanos: 0,
},
},
testStepId: '6',
testCaseStartedId: '7',
},
},
{
testCaseFinished: {
testResult: {
status: 'PASSED',
duration: {
seconds: '0',
nanos: 0,
},
},
testCaseStartedId: '7',
},
},
{
testRunFinished: {
success: true,
},
},
]