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

cli: use kebab-case for --retry-tag-filter arg #1293

Merged
merged 14 commits into from
Mar 17, 2020
Prev Previous commit
Next Next commit
switch to kebab-case
davidjgoss committed Feb 20, 2020
commit 0dfedecd725fd372a4f580b41f5703a3e2b11c6a
2 changes: 1 addition & 1 deletion dist/cucumber.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions features/retry.feature
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Feature: Retry flaky tests

Using the `--retry` flag will retry failing tests for the specified number of times
Additionally using the `--retryTagFilter` flag will re-run only tests matching the tag expression
Additionally using the `--retry-tag-filter` flag will re-run only tests matching the tag expression

@spawn
Scenario: running Cucumber JS with --retryTagFilter but no positive --retry will fail
When I run cucumber-js with `--retryTagFilter @flaky`
Scenario: running Cucumber JS with --retry-tag-filter but no positive --retry will fail
When I run cucumber-js with `--retry-tag-filter @flaky`
Then the error output contains the text:
"""
Error: a positive --retry count must be specified when setting --retryTagFilter
Error: a positive --retry count must be specified when setting --retry-tag-filter
"""
And it fails

@@ -322,7 +322,7 @@ Feature: Retry flaky tests
"""
And it fails

Scenario: retrying a flaky test matching --retryTagFilter will eventually make it pass
Scenario: retrying a flaky test matching --retry-tag-filter will eventually make it pass
Given a file named "features/a.feature" with:
"""
Feature:
@@ -344,12 +344,12 @@ Feature: Retry flaky tests
throw 'fail'
})
"""
When I run cucumber-js with `--retry 1 --retryTagFilter '@flaky'`
When I run cucumber-js with `--retry 1 --retry-tag-filter '@flaky'`
Then scenario "Flaky" attempt 0 step "Given a flaky step" has status "failed"
Then scenario "Flaky" attempt 1 step "Given a flaky step" has status "passed"
And it passes

Scenario: a flaky test not matching --retryTagFilter won't re-run and just fail
Scenario: a flaky test not matching --retry-tag-filter won't re-run and just fail
Given a file named "features/a.feature" with:
"""
Feature:
@@ -371,11 +371,11 @@ Feature: Retry flaky tests
throw 'fail'
})
"""
When I run cucumber-js with `--retry 1 --retryTagFilter '@not_flaky'`
When I run cucumber-js with `--retry 1 --retry-tag-filter '@not_flaky'`
Then scenario "Flaky" step "Given a flaky step" has status "failed"
And it fails

Scenario: retrying a flaky test matching --retryTagFilter will eventually make it pass but not-matching will not be retried (AND operator between tags)
Scenario: retrying a flaky test matching --retry-tag-filter will eventually make it pass but not-matching will not be retried (AND operator between tags)
Given a file named "features/a.feature" with:
"""
Feature:
@@ -410,13 +410,13 @@ Feature: Retry flaky tests
throw 'fail'
})
"""
When I run cucumber-js with `--retry 1 --retryTagFilter '@flaky and @anOtherTag'`
When I run cucumber-js with `--retry 1 --retry-tag-filter '@flaky and @anOtherTag'`
Then scenario "Flaky" attempt 0 step "Given a flaky step" has status "failed"
Then scenario "Flaky" attempt 1 step "Given a flaky step" has status "passed"
And scenario "Also Flaky" step "Given an other flaky step" has status "failed"
And it fails

Scenario: retrying a flaky test matching --retryTagFilter will eventually make it pass but not-matching will not be retried (OR operator between tags)
Scenario: retrying a flaky test matching --retry-tag-filter will eventually make it pass but not-matching will not be retried (OR operator between tags)
Given a file named "features/a.feature" with:
"""
Feature:
@@ -464,7 +464,7 @@ Feature: Retry flaky tests
throw 'fail'
})
"""
When I run cucumber-js with `--retry 1 --retryTagFilter '@anOtherTag or @oneMoreTag'`
When I run cucumber-js with `--retry 1 --retry-tag-filter '@anOtherTag or @oneMoreTag'`
Then scenario "Flaky" attempt 0 step "Given a flaky step" has status "failed"
And scenario "Flaky" attempt 1 step "Given a flaky step" has status "passed"
And scenario "Also Flaky" attempt 0 step "Given an other flaky step" has status "failed"
6 changes: 3 additions & 3 deletions src/cli/argv_parser.ts
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ const ArgvParser = {
return value
},

validateRetryOptions(options: IParsedArgvOptions): void {
validateRetryOptions(argv: string[], options: IParsedArgvOptions): void {
if (options.retryTagFilter !== '' && options.retry === 0) {
throw new Error(
'a positive --retry count must be specified when setting --retry-tag-filter'
@@ -188,7 +188,7 @@ const ArgvParser = {
0
)
.option(
'--retryTagFilter <EXPRESSION>',
'--retry-tag-filter <EXPRESSION>',
`only retries the features or scenarios with tags matching the expression (repeatable).
This option requires '--retry' to be specified.`,
ArgvParser.mergeTags,
@@ -217,7 +217,7 @@ const ArgvParser = {

program.parse(argv)
const options = program.opts() as IParsedArgvOptions
ArgvParser.validateRetryOptions(options)
ArgvParser.validateRetryOptions(argv, options)

return {
options,