-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathparallel.feature
128 lines (111 loc) · 3.81 KB
/
parallel.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Feature: Running scenarios in parallel
Scenario: running in parallel can improve speed if there are async operations
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a slow step$/, function(callback) {
setTimeout(callback, 1000)
})
"""
And a file named "features/a.feature" with:
"""
Feature: slow
Scenario: a
Given a slow step
Scenario: b
Given a slow step
"""
When I run cucumber-js with `--parallel 2`
Then it passes
@spawn
Scenario: an error in BeforeAll fails the test
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {BeforeAll, Given} = require('@cucumber/cucumber')
Given(/^a slow step$/, function(callback) {
setTimeout(callback, 1000)
})
BeforeAll(function() {
throw new Error('my error')
})
"""
And a file named "features/a.feature" with:
"""
Feature: slow
Scenario: a
Given a slow step
"""
When I run cucumber-js with `--parallel 2`
And the error output contains the text:
"""
BeforeAll hook errored on worker 0, process exiting:
"""
And the error output contains the text:
"""
BeforeAll hook errored on worker 1, process exiting:
"""
And the error output contains the text:
"""
my error
"""
Then it fails
Scenario: `testCaseStarted` envelope from workers contains `workerId` parameter
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a slow step$/, function(callback) {
setTimeout(callback, 1000)
})
"""
And a file named "features/a.feature" with:
"""
Feature: slow
Scenario: a
Given a slow step
Scenario: b
Given a slow step
"""
When I run cucumber-js with `--parallel 2`
Then it passes
And `testCaseStarted` envelope has `workerId`
Scenario: running in parallel respects `parallelCanAssign` rules on retried scenarios
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {When, setParallelCanAssign} = require('@cucumber/cucumber')
When(/^I wait slowly$/, function(callback) {
setTimeout(callback, 200 * 2)
})
When(/^I wait quickly$/, function(callback) {
setTimeout(callback, 200 * 1)
})
let counter = 0;
When(/^I fail and have to retry$/, function() {
counter += 1;
if (counter < 4) {
throw new Error('Failed as expected')
}
})
setParallelCanAssign(function(pickleInQuestion, picklesInProgress) {
const runningCount = picklesInProgress.length;
const picklesInProgressAllInParallel = picklesInProgress.every(p => p.tags.find(t => t.name === '@parallel') !== undefined);
const shouldRunInParallel = pickleInQuestion.tags.find((t) => t.name === '@parallel') !== undefined;
return ((!shouldRunInParallel && runningCount < 1) || shouldRunInParallel) && picklesInProgressAllInParallel;
})
"""
And a file named "features/a.feature" with:
"""
Feature: Testing parallelism with retries
@parallel
Scenario: fail_parallel
When I wait quickly
And I fail and have to retry
@parallel
Scenario: pass_parallel
When I wait slowly
Scenario: pass_sync
When I wait quickly
"""
When I run cucumber-js with `--parallel 2 --retry 3`
Then it passes
And the first two scenarios run in parallel while the last runs sequentially
And the scenario 'fail_parallel' retried 3 times