gurke 3.2.2 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +10 -0
- data/features/gurke.rb +2 -0
- data/features/gurke/retry_flaky_scenario.feature +70 -0
- data/features/gurke/retry_scenario.feature +12 -12
- data/gurke.gemspec +1 -1
- data/lib/gurke/configuration.rb +18 -0
- data/lib/gurke/reporters/default_reporter.rb +6 -2
- data/lib/gurke/runner.rb +4 -0
- data/lib/gurke/scenario.rb +14 -8
- data/lib/gurke/version.rb +2 -2
- data/spec/gurke/reporters/default_reporter_spec.rb +28 -7
- data/spec/gurke/scenario_spec.rb +2 -4
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19dece7b4b59ad3477927b3e8fe8a999d16dd38c76eaf47da0884364a0cf6304
|
4
|
+
data.tar.gz: 6fd2ad924d46cfb1be7df5d8e8d7aab48d135954168833253155cde3178e56d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe0d861f4689b7b9dfd04f98c5237193e1adfe5d131b43d3db92ba401f300e008d5c1c225ca1cc5c1858da9f1a774ba6246d5cf583727c9b0360f5316aa579e
|
7
|
+
data.tar.gz: 8883a08e2d30485bf1a765bc5bb9101aebc39d37155b9bc98c3c20bed9891b1815e0f2699b61effe1a48ba73233ca91db05807e01730970bc4b8d9f0f92a897b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -176,6 +176,16 @@ Feature: F
|
|
176
176
|
|
177
177
|
Gurke will retry a marked scenario only once if a step failed.
|
178
178
|
|
179
|
+
### Formatter
|
180
|
+
|
181
|
+
You can choose another formatter using a command line switch:
|
182
|
+
|
183
|
+
```
|
184
|
+
gurke -f team_city
|
185
|
+
```
|
186
|
+
|
187
|
+
Available formatters include: `default`, `compact`, `null` and `team_city`.
|
188
|
+
|
179
189
|
### DRb background server (experimental)
|
180
190
|
|
181
191
|
You can run a DRb server in the background that has a running test environment (whatever that means to you) by running `gurke --drb-server`. This will load your test environment and execute all before `:system` hooks.
|
data/features/gurke.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
Feature: Flagged flaky scenarios
|
2
|
+
In order to fail less often with flaky scenarios
|
3
|
+
As a CI administrator and tester
|
4
|
+
I want to have marked scenarios retried
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file "features/support/steps/test_steps.rb" with the following content exists
|
8
|
+
"""
|
9
|
+
$try = 0
|
10
|
+
|
11
|
+
module TestSteps
|
12
|
+
step("I fail the first time") do
|
13
|
+
fail 'first time' if ($try += 1) < 2
|
14
|
+
end
|
15
|
+
|
16
|
+
step("I fail always") do
|
17
|
+
fail 'always'
|
18
|
+
end
|
19
|
+
|
20
|
+
step("I do not fail") do
|
21
|
+
# noop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Gurke.configure{|c| c.include TestSteps }
|
26
|
+
"""
|
27
|
+
|
28
|
+
Scenario: Run a flaky scenario
|
29
|
+
Given a file "features/test.feature" with the following content exists
|
30
|
+
"""
|
31
|
+
Feature: F
|
32
|
+
@flaky
|
33
|
+
Scenario: Scenario Failure
|
34
|
+
Given I fail the first time
|
35
|
+
"""
|
36
|
+
When I run the tests
|
37
|
+
Then the program exit code should be null
|
38
|
+
And the program output should include "Given I fail the first time (failure)"
|
39
|
+
And the program output should include "Given I fail the first time (passed)"
|
40
|
+
And the program output should include "Retry flaky scenario due to previous failure:"
|
41
|
+
And the program output should include "1 scenarios: 0 failing, 0 pending"
|
42
|
+
|
43
|
+
Scenario: Run a marked but always failing scenario
|
44
|
+
Given a file "features/test.feature" with the following content exists
|
45
|
+
"""
|
46
|
+
Feature: F
|
47
|
+
@flaky
|
48
|
+
Scenario: Scenario Failure
|
49
|
+
Given I fail always
|
50
|
+
"""
|
51
|
+
When I run the tests
|
52
|
+
Then the program exit code should be non-null
|
53
|
+
And the program output should include "Given I fail always (failure)"
|
54
|
+
And the program output should include "Retry flaky scenario due to previous failure:"
|
55
|
+
And the program output should not include "Given I fail always (passed)"
|
56
|
+
And the program output should include "1 scenarios: 1 failing, 0 pending"
|
57
|
+
|
58
|
+
Scenario: Run a marked but passing scenario
|
59
|
+
Given a file "features/test.feature" with the following content exists
|
60
|
+
"""
|
61
|
+
Feature: F
|
62
|
+
@flaky
|
63
|
+
Scenario: Scenario Failure
|
64
|
+
Given I do not fail
|
65
|
+
"""
|
66
|
+
When I run the tests
|
67
|
+
Then the program exit code should be null
|
68
|
+
And the program output should include "Given I do not fail (passed)"
|
69
|
+
And the program output should not include "Retry flaky scenario due to previous failure:"
|
70
|
+
And the program output should include "1 scenarios: 0 failing, 0 pending"
|
@@ -1,7 +1,7 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: Retry scenarios
|
2
2
|
In order to fail less often with flaky scenarios
|
3
3
|
As a CI administrator and tester
|
4
|
-
I want to have
|
4
|
+
I want to have all scenarios retried
|
5
5
|
|
6
6
|
Background:
|
7
7
|
Given a file "features/support/steps/test_steps.rb" with the following content exists
|
@@ -22,14 +22,16 @@ Feature: Pending Steps
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
Gurke.configure
|
25
|
+
Gurke.configure do |c|
|
26
|
+
c.include TestSteps
|
27
|
+
c.default_retries = 1
|
28
|
+
end
|
26
29
|
"""
|
27
30
|
|
28
|
-
Scenario:
|
31
|
+
Scenario: Retry a failed scenario
|
29
32
|
Given a file "features/test.feature" with the following content exists
|
30
33
|
"""
|
31
34
|
Feature: F
|
32
|
-
@flaky
|
33
35
|
Scenario: Scenario Failure
|
34
36
|
Given I fail the first time
|
35
37
|
"""
|
@@ -37,34 +39,32 @@ Feature: Pending Steps
|
|
37
39
|
Then the program exit code should be null
|
38
40
|
And the program output should include "Given I fail the first time (failure)"
|
39
41
|
And the program output should include "Given I fail the first time (passed)"
|
40
|
-
And the program output should include "Retry
|
42
|
+
And the program output should include "Retry scenario due to previous failure:"
|
41
43
|
And the program output should include "1 scenarios: 0 failing, 0 pending"
|
42
44
|
|
43
|
-
Scenario: Run
|
45
|
+
Scenario: Run an always failing scenario
|
44
46
|
Given a file "features/test.feature" with the following content exists
|
45
47
|
"""
|
46
48
|
Feature: F
|
47
|
-
@flaky
|
48
49
|
Scenario: Scenario Failure
|
49
50
|
Given I fail always
|
50
51
|
"""
|
51
52
|
When I run the tests
|
52
53
|
Then the program exit code should be non-null
|
53
54
|
And the program output should include "Given I fail always (failure)"
|
54
|
-
And the program output should include "Retry
|
55
|
+
And the program output should include "Retry scenario due to previous failure:"
|
55
56
|
And the program output should not include "Given I fail always (passed)"
|
56
57
|
And the program output should include "1 scenarios: 1 failing, 0 pending"
|
57
58
|
|
58
|
-
Scenario: Run a
|
59
|
+
Scenario: Run a passing scenario
|
59
60
|
Given a file "features/test.feature" with the following content exists
|
60
61
|
"""
|
61
62
|
Feature: F
|
62
|
-
@flaky
|
63
63
|
Scenario: Scenario Failure
|
64
64
|
Given I do not fail
|
65
65
|
"""
|
66
66
|
When I run the tests
|
67
67
|
Then the program exit code should be null
|
68
68
|
And the program output should include "Given I do not fail (passed)"
|
69
|
-
And the program output should not include "Retry
|
69
|
+
And the program output should not include "Retry scenario due to previous failure:"
|
70
70
|
And the program output should include "1 scenarios: 0 failing, 0 pending"
|
data/gurke.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
34
34
|
|
35
|
-
if ENV['TRAVIS_BUILD_NUMBER']
|
35
|
+
if ENV['TRAVIS_BUILD_NUMBER'] && !ENV['TRAVIS_TAG']
|
36
36
|
# Append travis build number for auto-releases
|
37
37
|
spec.version = "#{spec.version}.1.b#{ENV['TRAVIS_BUILD_NUMBER']}"
|
38
38
|
end
|
data/lib/gurke/configuration.rb
CHANGED
@@ -4,7 +4,25 @@ require 'forwardable'
|
|
4
4
|
|
5
5
|
module Gurke
|
6
6
|
class Configuration
|
7
|
+
# @api private
|
8
|
+
def initialize
|
9
|
+
@default_retries = 0
|
10
|
+
@flaky_retries = 1
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# How often a scenario is retries on failure by default.
|
15
|
+
#
|
16
|
+
# Defaults to none (0).
|
7
17
|
#
|
18
|
+
attr_accessor :default_retries
|
19
|
+
|
20
|
+
# How often a scenario marked as flaky is retries.
|
21
|
+
#
|
22
|
+
# Defaults to one (1).
|
23
|
+
#
|
24
|
+
attr_accessor :flaky_retries
|
25
|
+
|
8
26
|
# Define a before filter running before given action.
|
9
27
|
#
|
10
28
|
# @example
|
@@ -73,8 +73,12 @@ module Gurke::Reporters
|
|
73
73
|
io.flush
|
74
74
|
end
|
75
75
|
|
76
|
-
def retry_scenario(
|
77
|
-
|
76
|
+
def retry_scenario(scenario)
|
77
|
+
if scenario.flaky?
|
78
|
+
io.print "\n Retry flaky scenario due to previous failure:\n\n"
|
79
|
+
else
|
80
|
+
io.print "\n Retry scenario due to previous failure:\n\n"
|
81
|
+
end
|
78
82
|
end
|
79
83
|
|
80
84
|
def after_scenario(*)
|
data/lib/gurke/runner.rb
CHANGED
@@ -34,6 +34,10 @@ module Gurke
|
|
34
34
|
features.filter(options, files).run self, reporter
|
35
35
|
end
|
36
36
|
|
37
|
+
def retries(scenario)
|
38
|
+
scenario.flaky? ? config.flaky_retries : config.default_retries
|
39
|
+
end
|
40
|
+
|
37
41
|
def hook(scope, world, context, &block)
|
38
42
|
config.hooks[scope].run world, context, &block
|
39
43
|
end
|
data/lib/gurke/scenario.rb
CHANGED
@@ -136,7 +136,7 @@ module Gurke
|
|
136
136
|
@state = :pending
|
137
137
|
end
|
138
138
|
|
139
|
-
def
|
139
|
+
def flaky?
|
140
140
|
@tags.any? {|t| t.name == 'flaky' }
|
141
141
|
end
|
142
142
|
|
@@ -159,17 +159,17 @@ module Gurke
|
|
159
159
|
def run(runner, reporter)
|
160
160
|
reporter.invoke :before_scenario, self
|
161
161
|
|
162
|
-
runner
|
163
|
-
run_scenario runner, reporter
|
164
|
-
end
|
162
|
+
_run(runner, reporter)
|
165
163
|
|
166
|
-
|
164
|
+
return unless failed?
|
165
|
+
|
166
|
+
(1..runner.retries(self)).each do
|
167
167
|
reporter.invoke :retry_scenario, self
|
168
168
|
reset!
|
169
169
|
|
170
|
-
runner
|
171
|
-
|
172
|
-
|
170
|
+
_run(runner, reporter)
|
171
|
+
|
172
|
+
break unless failed?
|
173
173
|
end
|
174
174
|
ensure
|
175
175
|
reporter.invoke :after_scenario, self
|
@@ -183,6 +183,12 @@ module Gurke
|
|
183
183
|
@exception = nil
|
184
184
|
end
|
185
185
|
|
186
|
+
def _run(runner, reporter)
|
187
|
+
runner.hook :scenario, self, world do
|
188
|
+
run_scenario runner, reporter
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
186
192
|
def run_scenario(runner, reporter)
|
187
193
|
reporter.invoke :start_scenario, self
|
188
194
|
|
data/lib/gurke/version.rb
CHANGED
@@ -175,13 +175,34 @@ RSpec.describe Gurke::Reporters::DefaultReporter do
|
|
175
175
|
|
176
176
|
subject { reporter.retry_scenario(scenario); super() }
|
177
177
|
|
178
|
-
|
179
|
-
|
180
|
-
.
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
178
|
+
context 'with normal scenario' do
|
179
|
+
before do
|
180
|
+
allow(scenario).to receive(:flaky?).and_return(false)
|
181
|
+
end
|
182
|
+
|
183
|
+
it do
|
184
|
+
is_expected.to eq unindent <<~TEXT
|
185
|
+
.
|
186
|
+
. Retry scenario due to previous failure:
|
187
|
+
.
|
188
|
+
.
|
189
|
+
TEXT
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context 'with flaky scenario' do
|
194
|
+
before do
|
195
|
+
allow(scenario).to receive(:flaky?).and_return(true)
|
196
|
+
end
|
197
|
+
|
198
|
+
it do
|
199
|
+
is_expected.to eq unindent <<~TEXT
|
200
|
+
.
|
201
|
+
. Retry flaky scenario due to previous failure:
|
202
|
+
.
|
203
|
+
.
|
204
|
+
TEXT
|
205
|
+
end
|
185
206
|
end
|
186
207
|
end
|
187
208
|
|
data/spec/gurke/scenario_spec.rb
CHANGED
@@ -51,16 +51,14 @@ describe Gurke::Scenario do
|
|
51
51
|
end_scenario after_scenario]
|
52
52
|
end
|
53
53
|
|
54
|
-
context 'with
|
54
|
+
context 'with retries' do
|
55
55
|
let(:step) { double('step') }
|
56
|
-
let(:tags) { [tag] }
|
57
|
-
let(:tag) { double('tag') }
|
58
56
|
let(:worlds) { Set.new }
|
59
57
|
|
60
58
|
before { scenario.steps << step }
|
61
59
|
|
62
60
|
before do
|
63
|
-
allow(
|
61
|
+
allow(runner).to receive(:retries).with(scenario).and_return(1)
|
64
62
|
end
|
65
63
|
|
66
64
|
it 'resets the world' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gurke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- features/gurke/include_by_tags.feature
|
87
87
|
- features/gurke/other_reporter.feature
|
88
88
|
- features/gurke/pending_steps.feature
|
89
|
+
- features/gurke/retry_flaky_scenario.feature
|
89
90
|
- features/gurke/retry_scenario.feature
|
90
91
|
- features/gurke/run_specific_directories.feature
|
91
92
|
- features/gurke/run_specific_scenarios.feature
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
145
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.7.
|
146
|
+
rubygems_version: 2.7.7
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: An alternative gherkin feature runner inspired by rspec and turnip.
|
@@ -155,6 +156,7 @@ test_files:
|
|
155
156
|
- features/gurke/include_by_tags.feature
|
156
157
|
- features/gurke/other_reporter.feature
|
157
158
|
- features/gurke/pending_steps.feature
|
159
|
+
- features/gurke/retry_flaky_scenario.feature
|
158
160
|
- features/gurke/retry_scenario.feature
|
159
161
|
- features/gurke/run_specific_directories.feature
|
160
162
|
- features/gurke/run_specific_scenarios.feature
|