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

Fix skip scenario retry #1531

Closed
Closed
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions features/docs/cli/retry_failing_tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,22 @@ Feature: Retry failing tests

3 scenarios (2 flaky, 1 passed)
"""

Scenario: Flaky scenario gives zero exit code in no-strict-flaky mode if flaky step fails, passes and skips scenario
And a scenario "Flaky-skip" that fails three times, passes and then skips scenario
When I run `cucumber --retry 3 --no-strict-flaky --format summary`
Then the output should contain:
"""
Flaky-skip feature
Flaky-skip ✗
Flaky-skip ✗
Flaky-skip ✗
Flaky-skip -
"""
And the output should contain:
"""

4 scenarios (2 flaky, 1 skipped, 1 passed)
"""
And it should pass

38 changes: 38 additions & 0 deletions features/lib/step_definitions/scenarios_and_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,41 @@ def snake_case(name)
Given('a step definition that looks like this:') do |content|
write_file("features/step_definitions/steps#{SecureRandom.uuid}.rb", content)
end

Given('a scenario {string} that fails three times, passes and then skips scenario') do |full_name|
name = snake_case(full_name)

create_feature("#{full_name} feature") do
create_scenario(full_name) do
"""
Given it three times, then passes
And it skips scenario
"""
end
end

write_file(
"features/step_definitions/#{name}_steps.rb",
step_definition('/^it skips scenario/', 'skip_this_scenario')
)

write_file(
"features/step_definitions/#{name}_steps.rb",
[
step_definition('/^it skips scenario/', 'skip_this_scenario'),
step_definition(
'/^it three times, then passes/',
[
"$#{name} ||= 0",
"$#{name} += 1",
"expect($#{name}).to be > 3"
]
)
].join("\n")
)

write_file(
"features/support/#{name}_init.rb",
" $#{name} = 0"
)
end