Skip to content

Commit

Permalink
add scenario for skip before flaky step
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardrudko committed Apr 17, 2021
1 parent 4adb959 commit e96c502
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 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,13 @@ 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 it should pass with:
"""
4 scenarios (2 flaky, 1 skipped, 1 passed)
"""

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

0 comments on commit e96c502

Please sign in to comment.