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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9474952db05f7f3aad5527b68c1258dc1042a16e0800ec6abb4ba3a1cf1a5062
4
- data.tar.gz: b90e18c038a138852a4c0ef1de09d61ca3b05f677bc871d49996775fd8deb262
3
+ metadata.gz: 19dece7b4b59ad3477927b3e8fe8a999d16dd38c76eaf47da0884364a0cf6304
4
+ data.tar.gz: 6fd2ad924d46cfb1be7df5d8e8d7aab48d135954168833253155cde3178e56d7
5
5
  SHA512:
6
- metadata.gz: 6a504262150c0f0d6ec569b87a77d58584e0d7bebf1345f11c92aeb4f174dc74e0307f382d94360a70f60f27dfe12e48ea445d30061c6faaefd66e432ad17193
7
- data.tar.gz: b4f543612efbb949c37d45e7a4bffe5b6e38d8cebe99e85b6dbd910eb0ccf29afe3968447f20e94db1c4b3451955b1b3d25c08e0f2dd02e828337a25b4f64b68
6
+ metadata.gz: 8fe0d861f4689b7b9dfd04f98c5237193e1adfe5d131b43d3db92ba401f300e008d5c1c225ca1cc5c1858da9f1a774ba6246d5cf583727c9b0360f5316aa579e
7
+ data.tar.gz: 8883a08e2d30485bf1a765bc5bb9101aebc39d37155b9bc98c3c20bed9891b1815e0f2699b61effe1a48ba73233ca91db05807e01730970bc4b8d9f0f92a897b
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.1
4
+
5
+ * Add option for default retry of failed scenarios
6
+ * Make number of default and flaky retries configurable
7
+
3
8
  ## 3.2.2
4
9
 
5
10
  * Fix some default reporter formatting issues
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.
@@ -4,6 +4,8 @@ require 'gurke/rspec'
4
4
  require 'tmpdir'
5
5
 
6
6
  Gurke.configure do |c|
7
+ c.default_retries = 0
8
+
7
9
  c.around(:scenario) do |scenario|
8
10
  Dir.mktmpdir('gurke') do |dir|
9
11
  @__root = Pathname.new(dir)
@@ -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: Pending Steps
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 marked scenarios retried once
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{|c| c.include TestSteps }
25
+ Gurke.configure do |c|
26
+ c.include TestSteps
27
+ c.default_retries = 1
28
+ end
26
29
  """
27
30
 
28
- Scenario: Run a flaky 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 flaky scenario due to previous failure:"
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 a marked but always failing scenario
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 flaky scenario due to previous failure:"
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 marked but passing scenario
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 flaky scenario due to previous failure:"
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"
@@ -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
@@ -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
- io.print "\n Retry flaky scenario due to previous failure:\n\n"
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(*)
@@ -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
@@ -136,7 +136,7 @@ module Gurke
136
136
  @state = :pending
137
137
  end
138
138
 
139
- def retryable?
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.hook :scenario, self, world do
163
- run_scenario runner, reporter
164
- end
162
+ _run(runner, reporter)
165
163
 
166
- if failed? && retryable?
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.hook :scenario, self, world do
171
- run_scenario runner, reporter
172
- end
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
 
@@ -3,8 +3,8 @@
3
3
  module Gurke
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 2
7
- PATCH = 2
6
+ MINOR = 3
7
+ PATCH = 1
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
10
10
 
@@ -175,13 +175,34 @@ RSpec.describe Gurke::Reporters::DefaultReporter do
175
175
 
176
176
  subject { reporter.retry_scenario(scenario); super() }
177
177
 
178
- it do
179
- is_expected.to eq unindent <<~TEXT
180
- .
181
- . Retry flaky scenario due to previous failure:
182
- .
183
- .
184
- TEXT
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
 
@@ -51,16 +51,14 @@ describe Gurke::Scenario do
51
51
  end_scenario after_scenario]
52
52
  end
53
53
 
54
- context 'with retry' do
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(tag).to receive(:name).and_return('flaky')
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.2.2
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-04-11 00:00:00.000000000 Z
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.6
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