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

Simplify tests #4

Merged
merged 2 commits into from
May 21, 2021
Merged
Changes from all 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
56 changes: 11 additions & 45 deletions features/parallel_custom_assign.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,7 @@ Feature: Running scenarios in parallel with custom assignment
When I run cucumber-js with `--parallel 2`
Then it passes

Scenario: assignment is appropriately applied and fails at last processed scenario 'a'
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given, setParallelCanAssign} = require('@cucumber/cucumber')
let flag = true
setParallelCanAssign(() => (flag = !flag))
Given(/^scenario (\d+)$/, function(scenario, cb) {
setTimeout(cb, 150)
})
"""
And a file named "features/a.feature" with:
"""
Feature: adheres to setParallelCanAssign handler
Scenario: a
Given scenario 1

Scenario: b
Given scenario 2

Scenario: c
Given scenario 3
"""
When I run cucumber-js with `--parallel 2`
Then it passes
And it runs tests in order b, c, a

Scenario: assignment is appropriately applied and fails at last processed scenario 'a'
Scenario: assignment is appropriately applied
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given, setParallelCanAssign} = require('@cucumber/cucumber')
Expand All @@ -87,49 +61,41 @@ Feature: Running scenarios in parallel with custom assignment
setParallelCanAssign((pickleInQuestion, picklesInProgress) => _.isEmpty(pickleInQuestion.tags)
|| _.every(picklesInProgress, ({tags}) => _.isEmpty(tags) || tags[0].name !== pickleInQuestion.tags[0].name))

function step_def(name, delay) {
return function(scenario, cb) {
if (worker == null) worker = name;
if (processed !== 3) {
expect(worker).to.eq(name)
expect(scenario).to.eq(++processed)
} else {
// Scenario 3 might get picked up by B as both are ready at this point
expect(scenario).to.eq(processed++)
}
function step_def(delay) {
return function(cb) {
setTimeout(cb, delay)
}
}

Given(/^scenario complex (\d+)$/, step_def('A', 300))
Given(/^scenario simple (\d+)$/, step_def('B', 200))
Given(/^complex step$/, step_def(300))
Given(/^simple step$/, step_def(200))
"""
And a file named "features/a.feature" with:
"""
Feature: adheres to setParallelCanAssign handler
@complex
Scenario: 1
Given scenario complex 1
Given complex step

@complex
Scenario: 2
Given scenario complex 2
Given complex step

@complex
Scenario: 3
Given scenario complex 3
Given complex step

@simple
Scenario: 4
Given scenario simple 1
Given simple step

@simple
Scenario: 5
Given scenario simple 2
Given simple step

@simple
Scenario: 6
Given scenario simple 3
Given simple step
"""
When I run cucumber-js with `--parallel 2`
Then it passes
Expand Down