|
| 1 | +Feature: Running scenarios using sharding |
| 2 | + As a developer running features |
| 3 | + I want a way to split my test execution across multiple independent processes |
| 4 | + So that I save time in my build pipeline |
| 5 | + |
| 6 | + Background: |
| 7 | + Given a file named "features/a.feature" with: |
| 8 | + """ |
| 9 | + Feature: some feature |
| 10 | + @a |
| 11 | + Scenario: first scenario |
| 12 | + Given a step |
| 13 | +
|
| 14 | + @b |
| 15 | + Scenario Outline: second scenario - <ID> |
| 16 | + Given a step |
| 17 | +
|
| 18 | + @c |
| 19 | + Examples: |
| 20 | + | ID | |
| 21 | + | X | |
| 22 | + | Y | |
| 23 | +
|
| 24 | + @d |
| 25 | + Examples: |
| 26 | + | ID | |
| 27 | + | Z | |
| 28 | + """ |
| 29 | + And a file named "features/step_definitions/cucumber_steps.js" with: |
| 30 | + """ |
| 31 | + const {Given} = require('@cucumber/cucumber') |
| 32 | +
|
| 33 | + Given('a step', function() {}) |
| 34 | + """ |
| 35 | + |
| 36 | + Scenario: run a single scenario |
| 37 | + When I run cucumber-js with `--shard 1/5` |
| 38 | + Then it passes |
| 39 | + And it runs the scenario "first scenario" |
| 40 | + |
| 41 | + Scenario: run every other scenario starting at 1 |
| 42 | + When I run cucumber-js with `--shard 1/2` |
| 43 | + Then it passes |
| 44 | + And it runs the scenarios: |
| 45 | + | NAME | |
| 46 | + | first scenario | |
| 47 | + | second scenario - Y | |
| 48 | + |
| 49 | + Scenario: run every 3rd scenario starting at 1 |
| 50 | + When I run cucumber-js with `--shard 1/3` |
| 51 | + Then it passes |
| 52 | + And it runs the scenarios: |
| 53 | + | NAME | |
| 54 | + | first scenario | |
| 55 | + | second scenario - Z | |
| 56 | + |
| 57 | + Scenario: run even scenarios |
| 58 | + When I run cucumber-js with `--shard 2/2` |
| 59 | + Then it passes |
| 60 | + And it runs the scenarios: |
| 61 | + | NAME | |
| 62 | + | second scenario - X | |
| 63 | + | second scenario - Z | |
| 64 | + |
| 65 | + Scenario: no scenarios in shard |
| 66 | + When I run cucumber-js with `--shard 5/5` |
| 67 | + Then it passes |
| 68 | + And it runs 0 scenarios |
| 69 | + |
| 70 | + Scenario: invalid shard option |
| 71 | + When I run cucumber-js with `--shard whoops` |
| 72 | + Then it fails |
| 73 | + And the error output contains the text: |
| 74 | + """ |
| 75 | + the shard option must be in the format <index>/<total> (e.g. 1/3) |
| 76 | + """ |
| 77 | + |
0 commit comments