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

Support repeatable tags option #940

Merged
merged 4 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ In order to store and reuse commonly used CLI options, you can add a `cucumber.j

## Tags

Use `--tags <EXPRESSION>` to run specific features or scenarios.
Use `--tags <EXPRESSION>` to run specific features or scenarios. This option is repeatable and the expressions will be merged with `and` operator.
`<EXPRESSION>` is a [cucumber tag expression](https://docs.cucumber.io/tag-expressions/).

## Transpilers
Expand Down
7 changes: 7 additions & 0 deletions features/target_specific_scenarios_by_tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Feature: Target specific scenarios
Then it fails
And it runs the scenario "first scenario"

Scenario: merge multiple tag expressions
When I run cucumber.js with `--tags @b --tags @d`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test would pass without your source code change (which is why its important to write your tests first) because second scenario - Z is the only scenario with @d. Thus without the repeatable option, I expect this to pass. Maybe switch to @a and @d?

Then it fails
And it runs the scenarios:
| NAME |
| second scenario - Z |

Scenario: run a single scenario outline
When I run cucumber.js with `--tags @b`
Then it fails
Expand Down
7 changes: 6 additions & 1 deletion src/cli/argv_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default class ArgvParser {
}
}

static mergeTags(val, memo) {
return memo === '' ? `(${val})` : `${memo} and (${val})`
}

static validateLanguage(val) {
if (!_.includes(_.keys(Gherkin.DIALECTS), val)) {
throw new Error('Unsupported ISO 639-1: ' + val)
Expand Down Expand Up @@ -89,7 +93,8 @@ export default class ArgvParser {
)
.option(
'-t, --tags <EXPRESSION>',
'only execute the features or scenarios with tags matching the expression',
'only execute the features or scenarios with tags matching the expression (repeatable)',
ArgvParser.mergeTags,
''
)
.option(
Expand Down