cucumber-core 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +48 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +39 -0
- data/.travis.yml +2 -3
- data/HISTORY.md +12 -1
- data/README.md +37 -43
- data/cucumber-core.gemspec +2 -0
- data/lib/cucumber/core.rb +5 -2
- data/lib/cucumber/core/ast.rb +1 -0
- data/lib/cucumber/core/ast/background.rb +1 -0
- data/lib/cucumber/core/ast/comment.rb +1 -0
- data/lib/cucumber/core/ast/data_table.rb +1 -0
- data/lib/cucumber/core/ast/describes_itself.rb +1 -0
- data/lib/cucumber/core/ast/doc_string.rb +1 -0
- data/lib/cucumber/core/ast/empty_background.rb +1 -0
- data/lib/cucumber/core/ast/empty_multiline_argument.rb +1 -0
- data/lib/cucumber/core/ast/examples_table.rb +1 -0
- data/lib/cucumber/core/ast/feature.rb +1 -0
- data/lib/cucumber/core/ast/location.rb +1 -0
- data/lib/cucumber/core/ast/names.rb +1 -0
- data/lib/cucumber/core/ast/outline_step.rb +1 -0
- data/lib/cucumber/core/ast/scenario.rb +1 -0
- data/lib/cucumber/core/ast/scenario_outline.rb +1 -0
- data/lib/cucumber/core/ast/step.rb +1 -0
- data/lib/cucumber/core/ast/tag.rb +1 -0
- data/lib/cucumber/core/compiler.rb +1 -0
- data/lib/cucumber/core/event.rb +63 -0
- data/lib/cucumber/core/event_bus.rb +64 -0
- data/lib/cucumber/core/events.rb +69 -0
- data/lib/cucumber/core/filter.rb +1 -0
- data/lib/cucumber/core/gherkin/ast_builder.rb +14 -5
- data/lib/cucumber/core/gherkin/document.rb +6 -4
- data/lib/cucumber/core/gherkin/parser.rb +6 -4
- data/lib/cucumber/core/gherkin/tag_expression.rb +1 -0
- data/lib/cucumber/core/gherkin/writer.rb +1 -0
- data/lib/cucumber/core/gherkin/writer/helpers.rb +1 -0
- data/lib/cucumber/core/platform.rb +1 -0
- data/lib/cucumber/core/report/summary.rb +30 -6
- data/lib/cucumber/core/test/action.rb +1 -0
- data/lib/cucumber/core/test/around_hook.rb +1 -0
- data/lib/cucumber/core/test/case.rb +13 -0
- data/lib/cucumber/core/test/filters.rb +1 -0
- data/lib/cucumber/core/test/filters/locations_filter.rb +1 -0
- data/lib/cucumber/core/test/filters/name_filter.rb +1 -0
- data/lib/cucumber/core/test/filters/tag_filter.rb +1 -0
- data/lib/cucumber/core/test/result.rb +5 -0
- data/lib/cucumber/core/test/runner.rb +10 -10
- data/lib/cucumber/core/test/step.rb +1 -0
- data/lib/cucumber/core/test/timer.rb +1 -0
- data/lib/cucumber/core/version.rb +2 -1
- data/spec/capture_warnings.rb +3 -2
- data/spec/coverage.rb +1 -0
- data/spec/cucumber/core/ast/background_spec.rb +1 -0
- data/spec/cucumber/core/ast/data_table_spec.rb +1 -0
- data/spec/cucumber/core/ast/doc_string_spec.rb +2 -1
- data/spec/cucumber/core/ast/empty_multiline_argument_spec.rb +1 -0
- data/spec/cucumber/core/ast/examples_table_spec.rb +1 -0
- data/spec/cucumber/core/ast/location_spec.rb +1 -0
- data/spec/cucumber/core/ast/outline_step_spec.rb +1 -0
- data/spec/cucumber/core/ast/step_spec.rb +1 -0
- data/spec/cucumber/core/compiler_spec.rb +1 -0
- data/spec/cucumber/core/event_bus_spec.rb +151 -0
- data/spec/cucumber/core/event_spec.rb +40 -0
- data/spec/cucumber/core/filter_spec.rb +1 -0
- data/spec/cucumber/core/gherkin/parser_spec.rb +24 -0
- data/spec/cucumber/core/gherkin/writer_spec.rb +1 -0
- data/spec/cucumber/core/report/summary_spec.rb +127 -0
- data/spec/cucumber/core/test/action_spec.rb +1 -0
- data/spec/cucumber/core/test/case_spec.rb +26 -2
- data/spec/cucumber/core/test/duration_matcher.rb +2 -1
- data/spec/cucumber/core/test/filters/locations_filter_spec.rb +2 -0
- data/spec/cucumber/core/test/result_spec.rb +5 -0
- data/spec/cucumber/core/test/runner_spec.rb +44 -50
- data/spec/cucumber/core/test/step_spec.rb +1 -0
- data/spec/cucumber/core/test/timer_spec.rb +1 -0
- data/spec/cucumber/core_spec.rb +68 -8
- data/spec/readme_spec.rb +1 -0
- data/spec/report_api_spy.rb +1 -0
- metadata +42 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# -*- coding: utf-8 -*-
|
|
2
3
|
require 'cucumber/core'
|
|
3
4
|
require 'cucumber/core/gherkin/writer'
|
|
@@ -13,8 +14,8 @@ module Cucumber
|
|
|
13
14
|
include Core::Gherkin::Writer
|
|
14
15
|
|
|
15
16
|
let(:test_case) { Test::Case.new(test_steps, [feature, scenario]) }
|
|
16
|
-
let(:feature) { double }
|
|
17
|
-
let(:scenario) { double }
|
|
17
|
+
let(:feature) { double(location: "features/test.feature:1") }
|
|
18
|
+
let(:scenario) { double(location: "features/test.feature:2") }
|
|
18
19
|
let(:test_steps) { [double, double] }
|
|
19
20
|
|
|
20
21
|
context 'describing itself' do
|
|
@@ -232,6 +233,29 @@ module Cucumber
|
|
|
232
233
|
end
|
|
233
234
|
end
|
|
234
235
|
|
|
236
|
+
describe "equality" do
|
|
237
|
+
it "is equal to another test case at the same location" do
|
|
238
|
+
gherkin = gherkin('features/foo.feature') do
|
|
239
|
+
feature do
|
|
240
|
+
scenario do
|
|
241
|
+
step
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
test_case_instances = []
|
|
246
|
+
receiver = double.as_null_object
|
|
247
|
+
allow(receiver).to receive(:test_case) do |test_case|
|
|
248
|
+
test_case_instances << test_case
|
|
249
|
+
end
|
|
250
|
+
2.times { compile([gherkin], receiver) }
|
|
251
|
+
expect(test_case_instances.length).to eq 2
|
|
252
|
+
expect(test_case_instances.uniq.length).to eq 1
|
|
253
|
+
expect(test_case_instances[0]).to be_eql test_case_instances[1]
|
|
254
|
+
expect(test_case_instances[0]).to eq test_case_instances[1]
|
|
255
|
+
expect(test_case_instances[0]).not_to equal test_case_instances[1]
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
235
259
|
end
|
|
236
260
|
end
|
|
237
261
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'cucumber/core/test/result'
|
|
3
4
|
require 'rspec/expectations'
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ module Cucumber::Core::Test
|
|
|
12
13
|
|
|
13
14
|
RSpec::Matchers.define :an_unknown_duration do
|
|
14
15
|
match do |actual|
|
|
15
|
-
actual.tap { raise "#tap block was executed, not an UnknownDuration" }
|
|
16
|
+
actual.tap { raise "#tap block was executed, not an UnknownDuration" }
|
|
16
17
|
expect(actual).to respond_to(:nanoseconds)
|
|
17
18
|
end
|
|
18
19
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'cucumber/core/gherkin/writer'
|
|
3
4
|
require 'cucumber/core'
|
|
4
5
|
require 'cucumber/core/test/filters/locations_filter'
|
|
@@ -364,6 +365,7 @@ module Cucumber::Core
|
|
|
364
365
|
end
|
|
365
366
|
|
|
366
367
|
max_duration_ms = 10000
|
|
368
|
+
max_duration_ms = max_duration_ms * 2.5 if defined?(JRUBY_VERSION)
|
|
367
369
|
it "filters #{num_features * num_scenarios_per_feature} test cases within #{max_duration_ms}ms" do
|
|
368
370
|
filter = Test::LocationsFilter.new(locations)
|
|
369
371
|
Timeout.timeout(max_duration_ms / 1000.0) do
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'cucumber/core/test/result'
|
|
3
4
|
require 'cucumber/core/test/duration_matcher'
|
|
4
5
|
|
|
@@ -118,6 +119,10 @@ module Cucumber::Core::Test
|
|
|
118
119
|
result.describe_to(visitor, args)
|
|
119
120
|
end
|
|
120
121
|
|
|
122
|
+
it "defines a with_filtered_backtrace method" do
|
|
123
|
+
expect(result.with_filtered_backtrace(double("filter"))).to eql result
|
|
124
|
+
end
|
|
125
|
+
|
|
121
126
|
specify { expect( result.to_sym ).to eq :unknown }
|
|
122
127
|
|
|
123
128
|
specify { expect( result ).not_to be_passed }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'cucumber/core/test/runner'
|
|
2
3
|
require 'cucumber/core/test/case'
|
|
3
4
|
require 'cucumber/core/test/step'
|
|
@@ -8,8 +9,8 @@ module Cucumber::Core::Test
|
|
|
8
9
|
|
|
9
10
|
let(:test_case) { Case.new(test_steps, source) }
|
|
10
11
|
let(:source) { [double('ast node', location: double)] }
|
|
11
|
-
let(:runner) { Runner.new(
|
|
12
|
-
let(:
|
|
12
|
+
let(:runner) { Runner.new(event_bus) }
|
|
13
|
+
let(:event_bus) { double.as_null_object }
|
|
13
14
|
let(:passing) { Step.new([source]).with_action {} }
|
|
14
15
|
let(:failing) { Step.new([source]).with_action { raise exception } }
|
|
15
16
|
let(:pending) { Step.new([source]).with_action { raise Result::Pending.new("TODO") } }
|
|
@@ -18,7 +19,7 @@ module Cucumber::Core::Test
|
|
|
18
19
|
let(:exception) { StandardError.new('test error') }
|
|
19
20
|
|
|
20
21
|
before do
|
|
21
|
-
allow(
|
|
22
|
+
allow(event_bus).to receive(:test_case_starting)
|
|
22
23
|
allow(source).to receive(:location)
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -31,7 +32,7 @@ module Cucumber::Core::Test
|
|
|
31
32
|
let(:test_steps) { [passing] }
|
|
32
33
|
|
|
33
34
|
it "records the nanoseconds duration of the execution on the result" do
|
|
34
|
-
expect(
|
|
35
|
+
expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
|
|
35
36
|
expect( result.duration ).to be_duration 1
|
|
36
37
|
end
|
|
37
38
|
test_case.describe_to runner
|
|
@@ -42,8 +43,8 @@ module Cucumber::Core::Test
|
|
|
42
43
|
let(:test_steps) { [failing] }
|
|
43
44
|
|
|
44
45
|
it "records the duration" do
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
46
|
+
expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
|
|
47
|
+
expect(result.duration).to be_duration 1
|
|
47
48
|
end
|
|
48
49
|
test_case.describe_to runner
|
|
49
50
|
end
|
|
@@ -53,8 +54,8 @@ module Cucumber::Core::Test
|
|
|
53
54
|
context "reporting the exception that failed a test case" do
|
|
54
55
|
let(:test_steps) { [failing] }
|
|
55
56
|
it "sets the exception on the result" do
|
|
56
|
-
allow(
|
|
57
|
-
expect(
|
|
57
|
+
allow(event_bus).to receive(:before_test_case)
|
|
58
|
+
expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
|
|
58
59
|
expect( result.exception ).to eq exception
|
|
59
60
|
end
|
|
60
61
|
test_case.describe_to runner
|
|
@@ -65,13 +66,13 @@ module Cucumber::Core::Test
|
|
|
65
66
|
context "without steps" do
|
|
66
67
|
let(:test_steps) { [] }
|
|
67
68
|
|
|
68
|
-
it "
|
|
69
|
-
expect(
|
|
69
|
+
it "emits a test_case_starting event before running the test case" do
|
|
70
|
+
expect(event_bus).to receive(:test_case_starting).with(test_case)
|
|
70
71
|
test_case.describe_to runner
|
|
71
72
|
end
|
|
72
73
|
|
|
73
|
-
it "
|
|
74
|
-
expect(
|
|
74
|
+
it "emits the test_case_finished event after running the the test case" do
|
|
75
|
+
expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
|
|
75
76
|
expect( reported_test_case ).to eq test_case
|
|
76
77
|
expect( result ).to be_unknown
|
|
77
78
|
end
|
|
@@ -83,8 +84,8 @@ module Cucumber::Core::Test
|
|
|
83
84
|
context 'that all pass' do
|
|
84
85
|
let(:test_steps) { [ passing, passing ] }
|
|
85
86
|
|
|
86
|
-
it '
|
|
87
|
-
expect(
|
|
87
|
+
it 'emits the test_case_finished event with a passing result' do
|
|
88
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
88
89
|
expect( result ).to be_passed
|
|
89
90
|
end
|
|
90
91
|
test_case.describe_to runner
|
|
@@ -94,8 +95,8 @@ module Cucumber::Core::Test
|
|
|
94
95
|
context 'an undefined step' do
|
|
95
96
|
let(:test_steps) { [ undefined ] }
|
|
96
97
|
|
|
97
|
-
it '
|
|
98
|
-
expect(
|
|
98
|
+
it 'emits the test_case_finished event with an undefined result' do
|
|
99
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
99
100
|
expect( result ).to be_undefined
|
|
100
101
|
end
|
|
101
102
|
allow( undefined.source.last ).to receive(:name)
|
|
@@ -103,7 +104,7 @@ module Cucumber::Core::Test
|
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
it 'sets the message on the result' do
|
|
106
|
-
expect(
|
|
107
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
107
108
|
expect( result.message ).to eq("Undefined step: \"step name\"")
|
|
108
109
|
end
|
|
109
110
|
expect( undefined.source.last ).to receive(:name).and_return("step name")
|
|
@@ -111,7 +112,7 @@ module Cucumber::Core::Test
|
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
it 'appends the backtrace of the result' do
|
|
114
|
-
expect(
|
|
115
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
115
116
|
expect( result.backtrace ).to eq(["step line"])
|
|
116
117
|
end
|
|
117
118
|
expect( undefined.source.last ).to receive(:backtrace_line).and_return("step line")
|
|
@@ -123,15 +124,15 @@ module Cucumber::Core::Test
|
|
|
123
124
|
context 'a pending step' do
|
|
124
125
|
let(:test_steps) { [ pending ] }
|
|
125
126
|
|
|
126
|
-
it '
|
|
127
|
-
expect(
|
|
127
|
+
it 'emits the test_case_finished event with a pending result' do
|
|
128
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
128
129
|
expect( result ).to be_pending
|
|
129
130
|
end
|
|
130
131
|
test_case.describe_to runner
|
|
131
132
|
end
|
|
132
133
|
|
|
133
134
|
it 'appends the backtrace of the result' do
|
|
134
|
-
expect(
|
|
135
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
135
136
|
expect( result.backtrace.last ).to eq("step line")
|
|
136
137
|
end
|
|
137
138
|
expect( pending.source.last ).to receive(:backtrace_line).and_return("step line")
|
|
@@ -142,15 +143,15 @@ module Cucumber::Core::Test
|
|
|
142
143
|
context "a skipping step" do
|
|
143
144
|
let(:test_steps) { [skipping] }
|
|
144
145
|
|
|
145
|
-
it "
|
|
146
|
-
expect(
|
|
146
|
+
it "emits the test_case_finished event with a skipped result" do
|
|
147
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
147
148
|
expect( result ).to be_skipped
|
|
148
149
|
end
|
|
149
150
|
test_case.describe_to runner
|
|
150
151
|
end
|
|
151
152
|
|
|
152
153
|
it 'appends the backtrace of the result' do
|
|
153
|
-
expect(
|
|
154
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
154
155
|
expect( result.backtrace.last ).to eq("step line")
|
|
155
156
|
end
|
|
156
157
|
expect( skipping.source.last ).to receive(:backtrace_line).and_return("step line")
|
|
@@ -161,15 +162,15 @@ module Cucumber::Core::Test
|
|
|
161
162
|
context 'that fail' do
|
|
162
163
|
let(:test_steps) { [ failing ] }
|
|
163
164
|
|
|
164
|
-
it '
|
|
165
|
-
expect(
|
|
165
|
+
it 'emits the test_case_finished event with a failing result' do
|
|
166
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
166
167
|
expect( result ).to be_failed
|
|
167
168
|
end
|
|
168
169
|
test_case.describe_to runner
|
|
169
170
|
end
|
|
170
171
|
|
|
171
172
|
it 'appends the backtrace of the exception of the result' do
|
|
172
|
-
expect(
|
|
173
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
173
174
|
expect( result.exception.backtrace.last ).to eq("step line")
|
|
174
175
|
end
|
|
175
176
|
expect( failing.source.last ).to receive(:backtrace_line).and_return("step line")
|
|
@@ -180,30 +181,22 @@ module Cucumber::Core::Test
|
|
|
180
181
|
context 'where the first step fails' do
|
|
181
182
|
let(:test_steps) { [ failing, passing ] }
|
|
182
183
|
|
|
183
|
-
it '
|
|
184
|
-
expect(
|
|
185
|
-
expect( result ).to be_failed
|
|
186
|
-
expect( result.exception ).to eq exception
|
|
187
|
-
end
|
|
188
|
-
test_case.describe_to runner
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it 'reports the first step as failed' do
|
|
192
|
-
expect( report ).to receive(:after_test_step).with(failing, anything) do |test_step, result|
|
|
184
|
+
it 'emits the test_step_finished event with a failed result' do
|
|
185
|
+
expect(event_bus).to receive(:test_step_finished).with(failing, anything) do |test_step, result|
|
|
193
186
|
expect( result ).to be_failed
|
|
194
187
|
end
|
|
195
188
|
test_case.describe_to runner
|
|
196
189
|
end
|
|
197
190
|
|
|
198
|
-
it '
|
|
199
|
-
expect(
|
|
191
|
+
it 'emits a test_step_finished event with a skipped result' do
|
|
192
|
+
expect(event_bus).to receive(:test_step_finished).with(passing, anything) do |test_step, result|
|
|
200
193
|
expect( result ).to be_skipped
|
|
201
194
|
end
|
|
202
195
|
test_case.describe_to runner
|
|
203
196
|
end
|
|
204
197
|
|
|
205
|
-
it '
|
|
206
|
-
expect(
|
|
198
|
+
it 'emits a test_case_finished event with a failed result' do
|
|
199
|
+
expect(event_bus).to receive(:test_case_finished) do |test_case, result|
|
|
207
200
|
expect( result ).to be_failed
|
|
208
201
|
expect( result.exception ).to eq exception
|
|
209
202
|
end
|
|
@@ -227,9 +220,10 @@ module Cucumber::Core::Test
|
|
|
227
220
|
let(:test_cases) { [first_test_case, last_test_case] }
|
|
228
221
|
|
|
229
222
|
it 'reports the results correctly for the following test case' do
|
|
230
|
-
expect(
|
|
231
|
-
expect(
|
|
232
|
-
|
|
223
|
+
expect(event_bus).to receive(:test_case_finished) { |reported_test_case, result|
|
|
224
|
+
expect(result).to be_failed if reported_test_case.equal?(first_test_case)
|
|
225
|
+
expect(result).to be_passed if reported_test_case.equal?(last_test_case)
|
|
226
|
+
}.twice
|
|
233
227
|
|
|
234
228
|
test_cases.each { |c| c.describe_to runner }
|
|
235
229
|
end
|
|
@@ -256,7 +250,7 @@ module Cucumber::Core::Test
|
|
|
256
250
|
around_hook = AroundHook.new { |block| block.call }
|
|
257
251
|
passing_step = Step.new([source]).with_action {}
|
|
258
252
|
test_case = Case.new([passing_step], source, [around_hook])
|
|
259
|
-
expect(
|
|
253
|
+
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
|
260
254
|
expect(result).to be_passed
|
|
261
255
|
end
|
|
262
256
|
test_case.describe_to runner
|
|
@@ -266,7 +260,7 @@ module Cucumber::Core::Test
|
|
|
266
260
|
around_hook = AroundHook.new { |block| raise exception }
|
|
267
261
|
passing_step = Step.new([source]).with_action {}
|
|
268
262
|
test_case = Case.new([passing_step], source, [around_hook])
|
|
269
|
-
expect(
|
|
263
|
+
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
|
270
264
|
expect(result).to be_failed
|
|
271
265
|
expect(result.exception).to eq exception
|
|
272
266
|
end
|
|
@@ -277,7 +271,7 @@ module Cucumber::Core::Test
|
|
|
277
271
|
around_hook = AroundHook.new { |block| block.call; raise exception }
|
|
278
272
|
passing_step = Step.new([source]).with_action {}
|
|
279
273
|
test_case = Case.new([passing_step], source, [around_hook])
|
|
280
|
-
expect(
|
|
274
|
+
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
|
281
275
|
expect(result).to be_failed
|
|
282
276
|
expect(result.exception).to eq exception
|
|
283
277
|
end
|
|
@@ -288,7 +282,7 @@ module Cucumber::Core::Test
|
|
|
288
282
|
around_hook = AroundHook.new { |block| block.call }
|
|
289
283
|
failing_step = Step.new([source]).with_action { raise exception }
|
|
290
284
|
test_case = Case.new([failing_step], source, [around_hook])
|
|
291
|
-
expect(
|
|
285
|
+
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
|
292
286
|
expect(result).to be_failed
|
|
293
287
|
expect(result.exception).to eq exception
|
|
294
288
|
end
|
|
@@ -300,11 +294,11 @@ module Cucumber::Core::Test
|
|
|
300
294
|
passing_step = Step.new([source]).with_action {}
|
|
301
295
|
test_case = Case.new([], source, [around_hook])
|
|
302
296
|
allow(runner).to receive(:running_test_step).and_return(passing_step)
|
|
303
|
-
expect(
|
|
297
|
+
expect(event_bus).to receive(:test_step_finished).with(passing_step, anything) do |reported_test_case, result|
|
|
304
298
|
expect(result).to be_failed
|
|
305
299
|
expect(result.exception).to eq exception
|
|
306
300
|
end
|
|
307
|
-
expect(
|
|
301
|
+
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
|
308
302
|
expect(result).to be_failed
|
|
309
303
|
expect(result.exception).to eq exception
|
|
310
304
|
end
|
data/spec/cucumber/core_spec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'report_api_spy'
|
|
2
3
|
require 'cucumber/core'
|
|
3
4
|
require 'cucumber/core/filter'
|
|
@@ -200,6 +201,61 @@ module Cucumber
|
|
|
200
201
|
end
|
|
201
202
|
|
|
202
203
|
describe "executing a test suite" do
|
|
204
|
+
|
|
205
|
+
it "fires events" do
|
|
206
|
+
gherkin = gherkin do
|
|
207
|
+
feature 'Feature name' do
|
|
208
|
+
scenario 'The one that passes' do
|
|
209
|
+
step 'passing'
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
scenario 'The one that fails' do
|
|
213
|
+
step 'passing'
|
|
214
|
+
step 'failing'
|
|
215
|
+
step 'passing'
|
|
216
|
+
step 'undefined'
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
observed_events = []
|
|
222
|
+
execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new] do |event_bus|
|
|
223
|
+
event_bus.on(:test_case_starting) do |event|
|
|
224
|
+
test_case = event.test_case
|
|
225
|
+
observed_events << [:test_case_starting, test_case.name]
|
|
226
|
+
end
|
|
227
|
+
event_bus.on(:test_case_finished) do |event|
|
|
228
|
+
test_case, result = *event.attributes
|
|
229
|
+
observed_events << [:test_case_finished, test_case.name, result.to_sym]
|
|
230
|
+
end
|
|
231
|
+
event_bus.on(:test_step_starting) do |event|
|
|
232
|
+
test_step = event.test_step
|
|
233
|
+
observed_events << [:test_step_starting, test_step.name]
|
|
234
|
+
end
|
|
235
|
+
event_bus.on(:test_step_finished) do |event|
|
|
236
|
+
test_step, result = *event.attributes
|
|
237
|
+
observed_events << [:test_step_finished, test_step.name, result.to_sym]
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
expect(observed_events).to eq [
|
|
242
|
+
[:test_case_starting, 'The one that passes'],
|
|
243
|
+
[:test_step_starting, 'passing'],
|
|
244
|
+
[:test_step_finished, 'passing', :passed],
|
|
245
|
+
[:test_case_finished, 'The one that passes', :passed],
|
|
246
|
+
[:test_case_starting, 'The one that fails'],
|
|
247
|
+
[:test_step_starting, 'passing'],
|
|
248
|
+
[:test_step_finished, 'passing', :passed],
|
|
249
|
+
[:test_step_starting, 'failing'],
|
|
250
|
+
[:test_step_finished, 'failing', :failed],
|
|
251
|
+
[:test_step_starting, 'passing'],
|
|
252
|
+
[:test_step_finished, 'passing', :skipped],
|
|
253
|
+
[:test_step_starting, 'undefined'],
|
|
254
|
+
[:test_step_finished, 'undefined', :undefined],
|
|
255
|
+
[:test_case_finished, 'The one that fails', :failed],
|
|
256
|
+
]
|
|
257
|
+
end
|
|
258
|
+
|
|
203
259
|
context "without hooks" do
|
|
204
260
|
it "executes the test cases in the suite" do
|
|
205
261
|
gherkin = gherkin do
|
|
@@ -216,9 +272,10 @@ module Cucumber
|
|
|
216
272
|
end
|
|
217
273
|
end
|
|
218
274
|
end
|
|
219
|
-
report = Core::Report::Summary.new
|
|
220
275
|
|
|
221
|
-
|
|
276
|
+
event_bus = Core::EventBus.new
|
|
277
|
+
report = Core::Report::Summary.new(event_bus)
|
|
278
|
+
execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new], event_bus
|
|
222
279
|
|
|
223
280
|
expect( report.test_cases.total ).to eq 2
|
|
224
281
|
expect( report.test_cases.total_passed ).to eq 1
|
|
@@ -258,10 +315,11 @@ module Cucumber
|
|
|
258
315
|
end
|
|
259
316
|
end
|
|
260
317
|
end
|
|
261
|
-
report = Core::Report::Summary.new
|
|
262
318
|
logger = []
|
|
263
319
|
|
|
264
|
-
|
|
320
|
+
event_bus = Core::EventBus.new
|
|
321
|
+
report = Core::Report::Summary.new(event_bus)
|
|
322
|
+
execute [gherkin], [WithAroundHooks.new(logger)], event_bus
|
|
265
323
|
|
|
266
324
|
expect( report.test_cases.total ).to eq 1
|
|
267
325
|
expect( report.test_cases.total_passed ).to eq 1
|
|
@@ -293,9 +351,10 @@ module Cucumber
|
|
|
293
351
|
end
|
|
294
352
|
end
|
|
295
353
|
end
|
|
296
|
-
report = Core::Report::Summary.new
|
|
297
354
|
|
|
298
|
-
|
|
355
|
+
event_bus = Core::EventBus.new
|
|
356
|
+
report = Core::Report::Summary.new(event_bus)
|
|
357
|
+
execute [gherkin], [ Cucumber::Core::Test::TagFilter.new(['@a']) ], event_bus
|
|
299
358
|
|
|
300
359
|
expect( report.test_cases.total ).to eq 2
|
|
301
360
|
end
|
|
@@ -311,9 +370,10 @@ module Cucumber
|
|
|
311
370
|
end
|
|
312
371
|
end
|
|
313
372
|
end
|
|
314
|
-
report = Core::Report::Summary.new
|
|
315
373
|
|
|
316
|
-
|
|
374
|
+
event_bus = Core::EventBus.new
|
|
375
|
+
report = Core::Report::Summary.new(event_bus)
|
|
376
|
+
execute [gherkin], [ Cucumber::Core::Test::NameFilter.new([/scenario/]) ], event_bus
|
|
317
377
|
|
|
318
378
|
expect( report.test_cases.total ).to eq 1
|
|
319
379
|
end
|