cucumber 7.1.0 → 9.2.1
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/README.md +17 -27
- data/VERSION +1 -0
- data/lib/cucumber/cli/configuration.rb +4 -1
- data/lib/cucumber/cli/main.rb +5 -4
- data/lib/cucumber/cli/options.rb +73 -67
- data/lib/cucumber/cli/profile_loader.rb +6 -10
- data/lib/cucumber/cli/rerun_file.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -6
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/deprecate.rb +6 -46
- data/lib/cucumber/errors.rb +3 -2
- data/lib/cucumber/events/envelope.rb +2 -0
- data/lib/cucumber/events/gherkin_source_parsed.rb +2 -0
- data/lib/cucumber/events/gherkin_source_read.rb +2 -0
- data/lib/cucumber/events/hook_test_step_created.rb +1 -2
- data/lib/cucumber/events/step_activated.rb +0 -6
- data/lib/cucumber/events/step_definition_registered.rb +0 -5
- data/lib/cucumber/events/test_case_created.rb +1 -2
- data/lib/cucumber/events/test_case_finished.rb +2 -0
- data/lib/cucumber/events/test_case_started.rb +2 -0
- data/lib/cucumber/events/test_run_finished.rb +2 -1
- data/lib/cucumber/events/test_step_created.rb +1 -2
- data/lib/cucumber/events/test_step_finished.rb +2 -0
- data/lib/cucumber/events/test_step_started.rb +2 -0
- data/lib/cucumber/events/undefined_parameter_type.rb +3 -2
- data/lib/cucumber/events.rb +1 -1
- data/lib/cucumber/file_specs.rb +2 -1
- data/lib/cucumber/filters/activate_steps.rb +1 -0
- data/lib/cucumber/filters/retry.rb +20 -1
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -3
- data/lib/cucumber/filters/tag_limits.rb +1 -3
- data/lib/cucumber/formatter/ansicolor.rb +70 -78
- data/lib/cucumber/formatter/ast_lookup.rb +16 -8
- data/lib/cucumber/formatter/backtrace_filter.rb +2 -1
- data/lib/cucumber/formatter/console.rb +26 -16
- data/lib/cucumber/formatter/console_counts.rb +3 -1
- data/lib/cucumber/formatter/console_issues.rb +10 -3
- data/lib/cucumber/formatter/curl_option_parser.rb +49 -0
- data/lib/cucumber/formatter/duration_extractor.rb +1 -0
- data/lib/cucumber/formatter/errors.rb +3 -0
- data/lib/cucumber/formatter/fail_fast.rb +1 -1
- data/lib/cucumber/formatter/fanout.rb +1 -1
- data/lib/cucumber/formatter/html.rb +2 -0
- data/lib/cucumber/formatter/http_io.rb +10 -137
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
- data/lib/cucumber/formatter/io.rb +5 -3
- data/lib/cucumber/formatter/io_http_buffer.rb +88 -0
- data/lib/cucumber/formatter/json.rb +10 -12
- data/lib/cucumber/formatter/junit.rb +10 -7
- data/lib/cucumber/formatter/message_builder.rb +24 -8
- data/lib/cucumber/formatter/pretty.rb +24 -10
- data/lib/cucumber/formatter/progress.rb +1 -0
- data/lib/cucumber/formatter/publish_banner_printer.rb +0 -2
- data/lib/cucumber/formatter/query/hook_by_test_step.rb +3 -0
- data/lib/cucumber/formatter/query/pickle_by_test.rb +2 -0
- data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +4 -0
- data/lib/cucumber/formatter/rerun.rb +5 -3
- data/lib/cucumber/formatter/summary.rb +1 -0
- data/lib/cucumber/formatter/unicode.rb +7 -7
- data/lib/cucumber/formatter/url_reporter.rb +3 -1
- data/lib/cucumber/formatter/usage.rb +3 -3
- data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +25 -27
- data/lib/cucumber/glue/dsl.rb +20 -25
- data/lib/cucumber/glue/hook.rb +6 -3
- data/lib/cucumber/glue/invoke_in_world.rb +5 -5
- data/lib/cucumber/glue/proto_world.rb +30 -34
- data/lib/cucumber/glue/registry_and_more.rb +15 -25
- data/lib/cucumber/glue/snippet.rb +4 -2
- data/lib/cucumber/glue/step_definition.rb +6 -3
- data/lib/cucumber/glue/world_factory.rb +2 -0
- data/lib/cucumber/hooks.rb +1 -0
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -1
- data/lib/cucumber/multiline_argument/data_table.rb +68 -80
- data/lib/cucumber/platform.rb +11 -16
- data/lib/cucumber/rake/task.rb +22 -15
- data/lib/cucumber/rspec/disable_option_parser.rb +6 -3
- data/lib/cucumber/running_test_case.rb +2 -1
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
- data/lib/cucumber/runtime/meta_message_builder.rb +108 -0
- data/lib/cucumber/runtime/support_code.rb +3 -0
- data/lib/cucumber/runtime/user_interface.rb +7 -6
- data/lib/cucumber/runtime.rb +22 -38
- data/lib/cucumber/step_match.rb +6 -4
- data/lib/cucumber/step_match_search.rb +3 -2
- data/lib/cucumber/term/ansicolor.rb +74 -50
- data/lib/cucumber/term/banner.rb +3 -0
- data/lib/cucumber.rb +2 -1
- data/lib/simplecov_setup.rb +1 -1
- metadata +95 -244
- data/CHANGELOG.md +0 -3131
- data/CONTRIBUTING.md +0 -250
- data/lib/autotest/cucumber.rb +0 -8
- data/lib/autotest/cucumber_mixin.rb +0 -130
- data/lib/autotest/cucumber_rails.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec2.rb +0 -8
- data/lib/autotest/cucumber_rspec.rb +0 -8
- data/lib/autotest/cucumber_rspec2.rb +0 -8
- data/lib/autotest/discover.rb +0 -13
- data/lib/cucumber/version +0 -1
@@ -54,7 +54,7 @@ module Cucumber
|
|
54
54
|
test_step, result = *event.attributes
|
55
55
|
return if @failing_test_step
|
56
56
|
|
57
|
-
@failing_test_step = test_step unless result.ok?(@config.strict)
|
57
|
+
@failing_test_step = test_step unless result.ok?(strict: @config.strict)
|
58
58
|
end
|
59
59
|
|
60
60
|
def on_test_case_finished(event)
|
@@ -71,7 +71,7 @@ module Cucumber
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def on_test_run_finished(_event)
|
74
|
-
@features_data.
|
74
|
+
@features_data.each_value { |data| end_feature(data) }
|
75
75
|
end
|
76
76
|
|
77
77
|
private
|
@@ -84,6 +84,7 @@ module Cucumber
|
|
84
84
|
uri = test_case.location.file
|
85
85
|
feature = @ast_lookup.gherkin_document(uri).feature
|
86
86
|
raise UnNamedFeatureError, uri if feature.name.empty?
|
87
|
+
|
87
88
|
@current_feature_data = @features_data[uri]
|
88
89
|
@current_feature_data[:uri] = uri unless @current_feature_data[:uri]
|
89
90
|
@current_feature_data[:feature] = feature unless @current_feature_data[:feature]
|
@@ -110,7 +111,8 @@ module Cucumber
|
|
110
111
|
scenario_source = @ast_lookup.scenario_source(test_case)
|
111
112
|
keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword
|
112
113
|
output = "#{keyword}: #{scenario}\n\n"
|
113
|
-
return output if result.ok?(@config.strict)
|
114
|
+
return output if result.ok?(strict: @config.strict)
|
115
|
+
|
114
116
|
if scenario_source.type == :Scenario
|
115
117
|
if @failing_test_step
|
116
118
|
if @failing_test_step.hook?
|
@@ -125,7 +127,7 @@ module Cucumber
|
|
125
127
|
else
|
126
128
|
output += "Example row: #{row_name}\n"
|
127
129
|
end
|
128
|
-
output
|
130
|
+
"#{output}\nMessage:\n"
|
129
131
|
end
|
130
132
|
|
131
133
|
def build_testcase(result, scenario_designation, output)
|
@@ -138,7 +140,7 @@ module Cucumber
|
|
138
140
|
testcase_attributes = get_testcase_attributes(classname, name, duration, filename)
|
139
141
|
|
140
142
|
@current_feature_data[:builder].testcase(testcase_attributes) do
|
141
|
-
if !result.passed? && result.ok?(@config.strict)
|
143
|
+
if !result.passed? && result.ok?(strict: @config.strict)
|
142
144
|
@current_feature_data[:builder].skipped
|
143
145
|
@current_feature_data[:skipped] += 1
|
144
146
|
elsif !result.passed?
|
@@ -191,7 +193,7 @@ module Cucumber
|
|
191
193
|
end
|
192
194
|
|
193
195
|
def basename(feature_file)
|
194
|
-
File.basename(feature_file.gsub(/[\\\/]/, '-'), '.feature')
|
196
|
+
File.basename(feature_file.gsub(/[\\\/]/, '-'), '.feature')
|
195
197
|
end
|
196
198
|
|
197
199
|
def write_file(feature_filename, data)
|
@@ -228,13 +230,14 @@ module Cucumber
|
|
228
230
|
end
|
229
231
|
|
230
232
|
def examples_table_row(row)
|
231
|
-
@row_name =
|
233
|
+
@row_name = "| #{row.cells.map(&:value).join(' | ')} |"
|
232
234
|
@name_suffix = " (outline example : #{@row_name})"
|
233
235
|
end
|
234
236
|
end
|
235
237
|
|
236
238
|
class ResultBuilder
|
237
239
|
attr_reader :test_case_duration
|
240
|
+
|
238
241
|
def initialize(result)
|
239
242
|
@test_case_duration = 0
|
240
243
|
result.describe_to(self)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
4
|
require 'cucumber/formatter/backtrace_filter'
|
3
5
|
require 'cucumber/formatter/query/hook_by_test_step'
|
@@ -40,11 +42,12 @@ module Cucumber
|
|
40
42
|
raise 'To be implemented'
|
41
43
|
end
|
42
44
|
|
43
|
-
def attach(src, media_type)
|
45
|
+
def attach(src, media_type, filename)
|
44
46
|
attachment_data = {
|
45
47
|
test_step_id: @current_test_step_id,
|
46
48
|
test_case_started_id: @current_test_case_started_id,
|
47
|
-
media_type: media_type
|
49
|
+
media_type: media_type,
|
50
|
+
file_name: filename
|
48
51
|
}
|
49
52
|
|
50
53
|
if media_type.start_with?('text/')
|
@@ -129,7 +132,7 @@ module Cucumber
|
|
129
132
|
@step_definitions_by_test_step.step_match_arguments(step).map do |argument|
|
130
133
|
Cucumber::Messages::StepMatchArgument.new(
|
131
134
|
group: argument_group_to_message(argument.group),
|
132
|
-
parameter_type_name: argument
|
135
|
+
parameter_type_name: parameter_type_name(argument)
|
133
136
|
)
|
134
137
|
end
|
135
138
|
end
|
@@ -142,6 +145,10 @@ module Cucumber
|
|
142
145
|
)
|
143
146
|
end
|
144
147
|
|
148
|
+
def parameter_type_name(step_match_argument)
|
149
|
+
step_match_argument.parameter_type&.name if step_match_argument.respond_to?(:parameter_type)
|
150
|
+
end
|
151
|
+
|
145
152
|
def on_test_run_started(*)
|
146
153
|
message = Cucumber::Messages::Envelope.new(
|
147
154
|
test_run_started: Cucumber::Messages::TestRunStarted.new(
|
@@ -190,10 +197,13 @@ module Cucumber
|
|
190
197
|
|
191
198
|
result_message = result.to_message
|
192
199
|
if result.failed? || result.pending?
|
200
|
+
message_element = result.failed? ? result.exception : result
|
201
|
+
|
193
202
|
result_message = Cucumber::Messages::TestStepResult.new(
|
194
203
|
status: result_message.status,
|
195
204
|
duration: result_message.duration,
|
196
|
-
message: create_error_message(
|
205
|
+
message: create_error_message(message_element),
|
206
|
+
exception: create_exception_object(result, message_element)
|
197
207
|
)
|
198
208
|
end
|
199
209
|
|
@@ -209,12 +219,17 @@ module Cucumber
|
|
209
219
|
output_envelope(message)
|
210
220
|
end
|
211
221
|
|
212
|
-
def create_error_message(
|
213
|
-
message_element = result.failed? ? result.exception : result
|
222
|
+
def create_error_message(message_element)
|
214
223
|
message = "#{message_element.message} (#{message_element.class})"
|
215
224
|
([message] + message_element.backtrace).join("\n")
|
216
225
|
end
|
217
226
|
|
227
|
+
def create_exception_object(result, message_element)
|
228
|
+
return unless result.failed?
|
229
|
+
|
230
|
+
Cucumber::Messages::Exception.from_h({ type: message_element.class, message: message_element.message })
|
231
|
+
end
|
232
|
+
|
218
233
|
def on_test_case_finished(event)
|
219
234
|
message = Cucumber::Messages::Envelope.new(
|
220
235
|
test_case_finished: Cucumber::Messages::TestCaseFinished.new(
|
@@ -226,10 +241,11 @@ module Cucumber
|
|
226
241
|
output_envelope(message)
|
227
242
|
end
|
228
243
|
|
229
|
-
def on_test_run_finished(
|
244
|
+
def on_test_run_finished(event)
|
230
245
|
message = Cucumber::Messages::Envelope.new(
|
231
246
|
test_run_finished: Cucumber::Messages::TestRunFinished.new(
|
232
|
-
timestamp: time_to_timestamp(Time.now)
|
247
|
+
timestamp: time_to_timestamp(Time.now),
|
248
|
+
success: event.success
|
233
249
|
)
|
234
250
|
)
|
235
251
|
|
@@ -19,16 +19,14 @@ module Cucumber
|
|
19
19
|
#
|
20
20
|
# If the output is STDOUT (and not a file), there are bright colours to watch too.
|
21
21
|
#
|
22
|
-
class Pretty
|
22
|
+
class Pretty
|
23
23
|
include FileUtils
|
24
24
|
include Console
|
25
25
|
include Io
|
26
26
|
include Cucumber::Gherkin::Formatter::Escaping
|
27
|
-
attr_reader :config, :options
|
27
|
+
attr_reader :config, :options, :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case, :in_scenario_outline, :print_background_steps
|
28
28
|
private :config, :options
|
29
|
-
attr_reader :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case
|
30
29
|
private :current_feature_uri, :current_scenario_outline, :current_examples, :current_test_case
|
31
|
-
attr_reader :in_scenario_outline, :print_background_steps
|
32
30
|
private :in_scenario_outline, :print_background_steps
|
33
31
|
|
34
32
|
def initialize(config)
|
@@ -105,16 +103,19 @@ module Cucumber
|
|
105
103
|
|
106
104
|
def on_test_step_started(event)
|
107
105
|
return if event.test_step.hook?
|
106
|
+
|
108
107
|
print_step_header(current_test_case) if first_step_after_printing_background_steps?(event.test_step)
|
109
108
|
end
|
110
109
|
|
111
110
|
def on_test_step_finished(event)
|
112
111
|
collect_snippet_data(event.test_step, @ast_lookup) if event.result.undefined?
|
113
112
|
return if in_scenario_outline && !options[:expand]
|
113
|
+
|
114
114
|
exception_to_be_printed = find_exception_to_be_printed(event.result)
|
115
115
|
print_step_data(event.test_step, event.result) if print_step_data?(event, exception_to_be_printed)
|
116
116
|
print_step_output
|
117
117
|
return unless exception_to_be_printed
|
118
|
+
|
118
119
|
print_exception(exception_to_be_printed, event.result.to_sym, 6)
|
119
120
|
@exceptions << exception_to_be_printed
|
120
121
|
end
|
@@ -127,6 +128,7 @@ module Cucumber
|
|
127
128
|
else
|
128
129
|
exception_to_be_printed = find_exception_to_be_printed(event.result)
|
129
130
|
return unless exception_to_be_printed
|
131
|
+
|
130
132
|
print_exception(exception_to_be_printed, event.result.to_sym, 6)
|
131
133
|
@exceptions << exception_to_be_printed
|
132
134
|
end
|
@@ -138,18 +140,25 @@ module Cucumber
|
|
138
140
|
print_summary
|
139
141
|
end
|
140
142
|
|
141
|
-
def attach(src, media_type)
|
143
|
+
def attach(src, media_type, filename)
|
142
144
|
return unless media_type == 'text/x.cucumber.log+plain'
|
143
|
-
|
145
|
+
|
146
|
+
if filename
|
147
|
+
@test_step_output.push("#{filename}: #{src}")
|
148
|
+
else
|
149
|
+
@test_step_output.push(src)
|
150
|
+
end
|
144
151
|
end
|
145
152
|
|
146
153
|
private
|
147
154
|
|
148
155
|
def find_exception_to_be_printed(result)
|
149
|
-
return nil if result.ok?(options[:strict])
|
156
|
+
return nil if result.ok?(strict: options[:strict])
|
157
|
+
|
150
158
|
result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
151
159
|
exception = result.failed? ? result.exception : result
|
152
160
|
return nil if @exceptions.include?(exception)
|
161
|
+
|
153
162
|
exception
|
154
163
|
end
|
155
164
|
|
@@ -196,6 +205,7 @@ module Cucumber
|
|
196
205
|
def feature_has_background?
|
197
206
|
feature_children = gherkin_document.feature.children
|
198
207
|
return false if feature_children.empty?
|
208
|
+
|
199
209
|
!feature_children.first.background.nil?
|
200
210
|
end
|
201
211
|
|
@@ -239,6 +249,7 @@ module Cucumber
|
|
239
249
|
def first_step_after_printing_background_steps?(test_step)
|
240
250
|
return false unless print_background_steps
|
241
251
|
return false unless test_step.location.lines.max >= current_test_case.location.lines.max
|
252
|
+
|
242
253
|
@print_background_steps = false
|
243
254
|
true
|
244
255
|
end
|
@@ -262,7 +273,8 @@ module Cucumber
|
|
262
273
|
def print_comments(up_to_line, indent_amount)
|
263
274
|
comments = gherkin_document.comments
|
264
275
|
return if comments.empty? || comments.length <= @next_comment_to_be_printed
|
265
|
-
|
276
|
+
|
277
|
+
comments[@next_comment_to_be_printed..].each do |comment|
|
266
278
|
if comment.location.line <= up_to_line
|
267
279
|
@io.puts(indent(format_string(comment.text.strip, :comment), indent_amount))
|
268
280
|
@next_comment_to_be_printed += 1
|
@@ -294,6 +306,7 @@ module Cucumber
|
|
294
306
|
|
295
307
|
def print_description(description)
|
296
308
|
return unless description
|
309
|
+
|
297
310
|
description.split("\n").each do |line|
|
298
311
|
@io.puts(line)
|
299
312
|
end
|
@@ -382,7 +395,7 @@ module Cucumber
|
|
382
395
|
end
|
383
396
|
end
|
384
397
|
|
385
|
-
def print_outline_data(scenario_outline)
|
398
|
+
def print_outline_data(scenario_outline)
|
386
399
|
print_comments(scenario_outline.location.line, 2)
|
387
400
|
print_tags(scenario_outline.tags, 2)
|
388
401
|
@source_indent = calculate_source_indent_for_ast_node(scenario_outline) if options[:source]
|
@@ -398,6 +411,7 @@ module Cucumber
|
|
398
411
|
end
|
399
412
|
@io.puts
|
400
413
|
next if options[:no_multiline]
|
414
|
+
|
401
415
|
print_doc_string(step.doc_string.content, :skipped, 6) unless step.doc_string.nil?
|
402
416
|
print_data_table(step.data_table, :skipped, 6) unless step.data_table.nil?
|
403
417
|
end
|
@@ -445,7 +459,7 @@ module Cucumber
|
|
445
459
|
language = ::Gherkin::Dialect.for(language_code)
|
446
460
|
scenario_keyword = language.scenario_keywords[0]
|
447
461
|
row = scenario_source(test_case).row
|
448
|
-
expanded_name =
|
462
|
+
expanded_name = "| #{row.cells.map(&:value).join(' | ')} |"
|
449
463
|
@source_indent = calculate_source_indent_for_expanded_test_case(test_case, scenario_keyword, expanded_name)
|
450
464
|
@io.puts
|
451
465
|
print_keyword_name(scenario_keyword, expanded_name, 6, test_case.location)
|
@@ -58,6 +58,7 @@ module Cucumber
|
|
58
58
|
progress(result.to_sym) if !test_step.hook? || result.failed?
|
59
59
|
|
60
60
|
return if test_step.hook?
|
61
|
+
|
61
62
|
collect_snippet_data(test_step, @ast_lookup) if result.undefined?
|
62
63
|
@pending_step_matches << @matches[test_step.to_s] if result.pending?
|
63
64
|
@failed_results << result if result.failed?
|
@@ -15,7 +15,6 @@ module Cucumber
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
18
|
def display_publish_ad(io)
|
20
19
|
display_banner(
|
21
20
|
[
|
@@ -59,7 +58,6 @@ module Cucumber
|
|
59
58
|
io
|
60
59
|
)
|
61
60
|
end
|
62
|
-
# rubocop:enable Metrics/MethodLength
|
63
61
|
|
64
62
|
def highlight(text)
|
65
63
|
[text, :cyan]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cucumber/formatter/errors'
|
2
4
|
|
3
5
|
module Cucumber
|
@@ -13,6 +15,7 @@ module Cucumber
|
|
13
15
|
|
14
16
|
def hook_id(test_step)
|
15
17
|
return @hook_id_by_test_step_id[test_step.id] if @hook_id_by_test_step_id.key?(test_step.id)
|
18
|
+
|
16
19
|
raise TestStepUnknownError, "No hook found for #{test_step.id} }. Known: #{@hook_id_by_test_step_id.keys}"
|
17
20
|
end
|
18
21
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cucumber/formatter/errors'
|
2
4
|
|
3
5
|
module Cucumber
|
@@ -15,11 +17,13 @@ module Cucumber
|
|
15
17
|
|
16
18
|
def attempt_by_test_case(test_case)
|
17
19
|
raise TestCaseUnknownError, "No test case found for #{test_case.id} }. Known: #{@attempts_by_test_case_id.keys}" unless @attempts_by_test_case_id.key?(test_case.id)
|
20
|
+
|
18
21
|
@attempts_by_test_case_id[test_case.id]
|
19
22
|
end
|
20
23
|
|
21
24
|
def test_case_started_id_by_test_case(test_case)
|
22
25
|
raise TestCaseUnknownError, "No test case found for #{test_case.id} }. Known: #{@test_case_started_id_by_test_case_id.keys}" unless @test_case_started_id_by_test_case_id.key?(test_case.id)
|
26
|
+
|
23
27
|
@test_case_started_id_by_test_case_id[test_case.id]
|
24
28
|
end
|
25
29
|
|
@@ -14,23 +14,25 @@ module Cucumber
|
|
14
14
|
config.on_event :test_case_finished do |event|
|
15
15
|
test_case, result = *event.attributes
|
16
16
|
if @config.strict.strict?(:flaky)
|
17
|
-
next if result.ok?(@config.strict)
|
17
|
+
next if result.ok?(strict: @config.strict)
|
18
|
+
|
18
19
|
add_to_failures(test_case)
|
19
20
|
else
|
20
21
|
unless @latest_failed_test_case.nil?
|
21
22
|
if @latest_failed_test_case != test_case
|
22
23
|
add_to_failures(@latest_failed_test_case)
|
23
24
|
@latest_failed_test_case = nil
|
24
|
-
elsif result.ok?(@config.strict)
|
25
|
+
elsif result.ok?(strict: @config.strict)
|
25
26
|
@latest_failed_test_case = nil
|
26
27
|
end
|
27
28
|
end
|
28
|
-
@latest_failed_test_case = test_case unless result.ok?(@config.strict)
|
29
|
+
@latest_failed_test_case = test_case unless result.ok?(strict: @config.strict)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
config.on_event :test_run_finished do
|
32
33
|
add_to_failures(@latest_failed_test_case) unless @latest_failed_test_case.nil?
|
33
34
|
next if @failures.empty?
|
35
|
+
|
34
36
|
@io.print file_failures.join("\n")
|
35
37
|
end
|
36
38
|
end
|
@@ -10,14 +10,14 @@ if Cucumber::WINDOWS
|
|
10
10
|
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
|
11
11
|
elsif `cmd /c chcp` =~ /(\d+)/
|
12
12
|
if [65_000, 65_001].include? Regexp.last_match(1).to_i
|
13
|
-
Cucumber::CODEPAGE = 'UTF-8'
|
13
|
+
Cucumber::CODEPAGE = 'UTF-8'
|
14
14
|
ENV['ANSICON_API'] = 'ruby'
|
15
15
|
else
|
16
|
-
Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}"
|
16
|
+
Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}"
|
17
17
|
end
|
18
18
|
else
|
19
|
-
Cucumber::CODEPAGE = 'cp1252'
|
20
|
-
|
19
|
+
Cucumber::CODEPAGE = 'cp1252'
|
20
|
+
$stderr.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
|
21
21
|
end
|
22
22
|
|
23
23
|
module Cucumber
|
@@ -28,7 +28,7 @@ if Cucumber::WINDOWS
|
|
28
28
|
def cucumber_preprocess_output(*out)
|
29
29
|
out.map { |arg| arg.to_s.encode(Encoding.default_external) }
|
30
30
|
rescue Encoding::UndefinedConversionError => e
|
31
|
-
|
31
|
+
$stderr.cucumber_puts("WARNING: #{e.message}")
|
32
32
|
out
|
33
33
|
end
|
34
34
|
|
@@ -45,8 +45,8 @@ if Cucumber::WINDOWS
|
|
45
45
|
end
|
46
46
|
|
47
47
|
Kernel.extend(self)
|
48
|
-
|
49
|
-
|
48
|
+
$stdout.extend(self)
|
49
|
+
$stderr.extend(self)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -78,7 +78,7 @@ module Cucumber
|
|
78
78
|
if @stepdef_to_match[stepdef_key].any?
|
79
79
|
print_steps(stepdef_key)
|
80
80
|
else
|
81
|
-
@io.puts(
|
81
|
+
@io.puts(" #{format_string('NOT MATCHED BY ANY STEPS', :failed)}")
|
82
82
|
end
|
83
83
|
end
|
84
84
|
@io.puts
|
@@ -86,7 +86,7 @@ module Cucumber
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def print_step_definition(stepdef_key)
|
89
|
-
@io.print format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped)
|
89
|
+
@io.print "#{format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped)} " unless config.dry_run?
|
90
90
|
@io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
|
91
91
|
if config.source?
|
92
92
|
indent_amount = max_length - stepdef_key.regexp_source.unpack('U*').length
|
@@ -99,7 +99,7 @@ module Cucumber
|
|
99
99
|
def print_steps(stepdef_key)
|
100
100
|
@stepdef_to_match[stepdef_key].each do |step|
|
101
101
|
@io.print ' '
|
102
|
-
@io.print format_string(format('%<duration>.7f', duration: step[:duration]), :skipped)
|
102
|
+
@io.print "#{format_string(format('%<duration>.7f', duration: step[:duration]), :skipped)} " unless config.dry_run?
|
103
103
|
@io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
|
104
104
|
if config.source?
|
105
105
|
indent_amount = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
|
@@ -5,8 +5,7 @@ module Cucumber
|
|
5
5
|
module Formatter
|
6
6
|
# Defines aliases for ANSI coloured output. Default colours can be overridden by defining
|
7
7
|
# a <tt>GHERKIN_COLORS</tt> variable in your shell, very much like how you can
|
8
|
-
# tweak the familiar POSIX command <tt>ls</tt> with
|
9
|
-
# $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
8
|
+
# tweak the familiar POSIX command <tt>ls</tt> with $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
10
9
|
#
|
11
10
|
# The colours that you can change are:
|
12
11
|
#
|
@@ -41,40 +40,39 @@ module Cucumber
|
|
41
40
|
# Although not listed, you can also use <tt>grey</tt>
|
42
41
|
module AnsiEscapes
|
43
42
|
COLORS = {
|
44
|
-
'black'
|
45
|
-
'red'
|
46
|
-
'green'
|
47
|
-
'yellow'
|
48
|
-
'blue'
|
43
|
+
'black' => "\e[30m",
|
44
|
+
'red' => "\e[31m",
|
45
|
+
'green' => "\e[32m",
|
46
|
+
'yellow' => "\e[33m",
|
47
|
+
'blue' => "\e[34m",
|
49
48
|
'magenta' => "\e[35m",
|
50
|
-
'cyan'
|
51
|
-
'white'
|
52
|
-
'grey'
|
53
|
-
'bold'
|
49
|
+
'cyan' => "\e[36m",
|
50
|
+
'white' => "\e[37m",
|
51
|
+
'grey' => "\e[90m",
|
52
|
+
'bold' => "\e[1m"
|
54
53
|
}.freeze
|
55
54
|
|
56
55
|
ALIASES = Hash.new do |h, k|
|
57
|
-
h[Regexp.last_match(1)]
|
56
|
+
"#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/
|
58
57
|
end.merge(
|
59
58
|
'undefined' => 'yellow',
|
60
|
-
'pending'
|
59
|
+
'pending' => 'yellow',
|
61
60
|
'executing' => 'grey',
|
62
|
-
'failed'
|
63
|
-
'passed'
|
64
|
-
'outline'
|
65
|
-
'skipped'
|
66
|
-
'comments'
|
67
|
-
'tag'
|
61
|
+
'failed' => 'red',
|
62
|
+
'passed' => 'green',
|
63
|
+
'outline' => 'cyan',
|
64
|
+
'skipped' => 'cyan',
|
65
|
+
'comments' => 'grey',
|
66
|
+
'tag' => 'cyan'
|
68
67
|
)
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
69
|
+
# Example: export GHERKIN_COLORS="passed=red:failed=yellow"
|
70
|
+
ENV.fetch('GHERKIN_COLORS', '').split(':').each do |pair|
|
71
|
+
rule, colour = pair.split('=')
|
72
|
+
ALIASES[colour] = rule
|
75
73
|
end
|
76
74
|
|
77
|
-
ALIASES.
|
75
|
+
ALIASES.each_key do |key|
|
78
76
|
define_method(key) do
|
79
77
|
ALIASES[key].split(',').map { |color| COLORS[color] }.join('')
|
80
78
|
end
|
@@ -88,8 +86,8 @@ module Cucumber
|
|
88
86
|
"\e[0m"
|
89
87
|
end
|
90
88
|
|
91
|
-
def up(
|
92
|
-
"\e[#{
|
89
|
+
def up(amount)
|
90
|
+
"\e[#{amount}A"
|
93
91
|
end
|
94
92
|
end
|
95
93
|
end
|