Skip to content

Commit 7b6302e

Browse files
committed
Detect and list flaky scenarios in the list of not ok scenarios
Also updated the retry feature for the separation of flaky scenarios to a separate category in the scenario counts.
1 parent 9a7147d commit 7b6302e

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

features/docs/cli/retry_failing_tests.feature

+26-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Feature: Retry failing tests
1414
Given a scenario "Fails-once" that fails once, then passes
1515
And a scenario "Fails-twice" that fails twice, then passes
1616
And a scenario "Solid" that passes
17-
And a scenario "Fails-forever" that fails
1817

1918
@todo-windows
2019
Scenario: Retry once, so Fails-once starts to pass
20+
Given a scenario "Fails-forever" that fails
2121
When I run `cucumber -q --retry 1 --format summary`
2222
Then it should fail with:
2323
"""
24-
7 scenarios (5 failed, 2 passed)
24+
4 scenarios (2 failed, 1 flaky, 1 passed)
2525
"""
2626
And it should fail with:
2727
"""
@@ -43,10 +43,11 @@ Feature: Retry failing tests
4343

4444
@todo-windows
4545
Scenario: Retry twice, so Fails-twice starts to pass too
46+
Given a scenario "Fails-forever" that fails
4647
When I run `cucumber -q --retry 2 --format summary`
4748
Then it should fail with:
4849
"""
49-
9 scenarios (6 failed, 3 passed)
50+
4 scenarios (1 failed, 2 flaky, 1 passed)
5051
"""
5152
And it should fail with:
5253
"""
@@ -67,3 +68,25 @@ Feature: Retry failing tests
6768
Fails-twice ✗
6869
Fails-twice ✓
6970
"""
71+
72+
@todo-windows
73+
Scenario: Flaky scenarios gives exit code zero in non-strict mode
74+
When I run `cucumber -q --retry 2 --format summary`
75+
Then it should pass with:
76+
"""
77+
78+
79+
3 scenarios (2 flaky, 1 passed)
80+
"""
81+
82+
@todo-windows
83+
Scenario: Flaky scenarios gives non-zero exit code in strict mode
84+
When I run `cucumber -q --retry 2 --format summary --strict`
85+
Then it should fail with:
86+
"""
87+
Flaky Scenarios:
88+
cucumber features/fails_once.feature:2
89+
cucumber features/fails_twice.feature:2
90+
91+
3 scenarios (2 flaky, 1 passed)
92+
"""

lib/cucumber/formatter/ansicolor.rb

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module ANSIColor
6060
end.merge({
6161
'undefined' => 'yellow',
6262
'pending' => 'yellow',
63+
'flaky' => 'yellow',
6364
'failed' => 'red',
6465
'passed' => 'green',
6566
'outline' => 'cyan',

lib/cucumber/formatter/console_issues.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ class ConsoleIssues
66
include Console
77

88
def initialize(config)
9+
@previous_test_case = nil
910
@issues = Hash.new { |h, k| h[k] = [] }
1011
@config = config
1112
@config.on_event(:test_case_finished) do |event|
12-
@issues[event.result.to_sym] << event.test_case unless event.result.ok?(@config.strict?)
13+
if event.test_case != @previous_test_case
14+
@previous_test_case = event.test_case
15+
@issues[event.result.to_sym] << event.test_case unless event.result.ok?(@config.strict?)
16+
elsif event.result.passed?
17+
@issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(@config.strict?)
18+
@issues[:failed].delete(event.test_case)
19+
end
1320
end
1421
end
1522

0 commit comments

Comments
 (0)