cucumber 2.99.0 → 3.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +22 -10
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +11 -4
- data/History.md +19 -1
- data/README.md +1 -1
- data/cucumber.gemspec +2 -2
- data/cucumber.yml +2 -2
- data/features/docs/api/listen_for_events.feature +7 -6
- data/features/docs/cli/help.feature +8 -0
- data/features/docs/cli/retry_failing_tests.feature +51 -16
- data/features/docs/defining_steps/nested_steps_i18n.feature +2 -0
- data/features/docs/defining_steps/printing_messages.feature +0 -1
- data/features/docs/defining_steps/skip_scenario.feature +0 -34
- data/features/docs/extending_cucumber/custom_formatter.feature +2 -30
- data/features/docs/formatters/summary_formatter.feature +34 -0
- data/features/docs/gherkin/unicode_table.feature +1 -1
- data/features/docs/post_configuration_hook.feature +0 -16
- data/features/docs/writing_support_code/world.feature +129 -0
- data/features/lib/step_definitions/aruba_steps.rb +1 -0
- data/features/lib/step_definitions/cli_steps.rb +4 -0
- data/features/lib/step_definitions/cucumber_steps.rb +1 -0
- data/features/lib/step_definitions/iso-8859-1_steps.rb +1 -0
- data/features/lib/step_definitions/json_steps.rb +1 -0
- data/features/lib/step_definitions/junit_steps.rb +1 -0
- data/features/lib/step_definitions/language_steps.rb +1 -0
- data/features/lib/step_definitions/profile_steps.rb +1 -0
- data/features/lib/step_definitions/retry_steps.rb +32 -12
- data/features/lib/step_definitions/ruby_steps.rb +1 -0
- data/features/lib/step_definitions/wire_steps.rb +1 -0
- data/features/lib/support/env.rb +2 -1
- data/features/lib/support/fake_wire_server.rb +1 -0
- data/features/lib/support/feature_factory.rb +1 -0
- data/features/lib/support/normalise_output.rb +1 -0
- data/gem_tasks/contributors.rake +1 -0
- data/gem_tasks/cov.rake +1 -0
- data/gem_tasks/cucumber.rake +1 -0
- data/gem_tasks/downloads.rb +1 -0
- data/gem_tasks/environment.rake +1 -0
- data/gem_tasks/examples.rake +2 -1
- data/gem_tasks/fix_cr_lf.rake +2 -1
- data/gem_tasks/flog.rake +2 -1
- data/gem_tasks/rspec.rake +1 -0
- data/gem_tasks/sass.rake +2 -1
- data/lib/autotest/cucumber.rb +1 -0
- data/lib/autotest/cucumber_mixin.rb +1 -0
- data/lib/autotest/cucumber_rails.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
- data/lib/autotest/cucumber_rspec.rb +1 -0
- data/lib/autotest/cucumber_rspec2.rb +1 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/cucumber.rb +1 -13
- data/lib/cucumber/cli/configuration.rb +3 -6
- data/lib/cucumber/cli/main.rb +2 -1
- data/lib/cucumber/cli/options.rb +239 -173
- data/lib/cucumber/cli/profile_loader.rb +1 -0
- data/lib/cucumber/cli/rerun_file.rb +1 -0
- data/lib/cucumber/configuration.rb +40 -19
- data/lib/cucumber/constantize.rb +1 -0
- data/lib/cucumber/core_ext/instance_exec.rb +1 -0
- data/lib/cucumber/core_ext/string.rb +1 -0
- data/lib/cucumber/deprecate.rb +1 -0
- data/lib/cucumber/encoding.rb +1 -0
- data/lib/cucumber/errors.rb +3 -1
- data/lib/cucumber/events.rb +13 -3
- data/lib/cucumber/events/step_definition_registered.rb +24 -0
- data/lib/cucumber/events/step_match.rb +4 -1
- data/lib/cucumber/events/test_run_finished.rb +12 -0
- data/lib/cucumber/file_specs.rb +1 -0
- data/lib/cucumber/filters.rb +2 -0
- data/lib/cucumber/filters/activate_steps.rb +2 -1
- data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
- data/lib/cucumber/filters/gated_receiver.rb +1 -0
- data/lib/cucumber/filters/prepare_world.rb +1 -0
- data/lib/cucumber/filters/quit.rb +1 -0
- data/lib/cucumber/filters/randomizer.rb +1 -0
- data/lib/cucumber/filters/retry.rb +3 -3
- data/lib/cucumber/filters/tag_limits.rb +1 -0
- data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -0
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -0
- data/lib/cucumber/formatter/ansicolor.rb +1 -0
- data/lib/cucumber/formatter/backtrace_filter.rb +3 -2
- data/lib/cucumber/formatter/console.rb +61 -52
- data/lib/cucumber/formatter/console_counts.rb +57 -0
- data/lib/cucumber/formatter/console_issues.rb +37 -0
- data/lib/cucumber/formatter/debug.rb +1 -0
- data/lib/cucumber/formatter/duration.rb +1 -0
- data/lib/cucumber/formatter/duration_extractor.rb +1 -0
- data/lib/cucumber/formatter/fail_fast.rb +4 -2
- data/lib/cucumber/formatter/fanout.rb +1 -0
- data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
- data/lib/cucumber/formatter/html.rb +6 -5
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -0
- data/lib/cucumber/formatter/interceptor.rb +1 -0
- data/lib/cucumber/formatter/io.rb +1 -0
- data/lib/cucumber/formatter/json.rb +15 -13
- data/lib/cucumber/formatter/json_pretty.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +13 -11
- data/lib/cucumber/formatter/legacy_api/adapter.rb +28 -32
- data/lib/cucumber/formatter/legacy_api/ast.rb +1 -0
- data/lib/cucumber/formatter/legacy_api/results.rb +1 -0
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +1 -0
- data/lib/cucumber/formatter/pretty.rb +7 -1
- data/lib/cucumber/formatter/progress.rb +56 -13
- data/lib/cucumber/formatter/rerun.rb +15 -18
- data/lib/cucumber/formatter/stepdefs.rb +1 -0
- data/lib/cucumber/formatter/steps.rb +1 -0
- data/lib/cucumber/formatter/summary.rb +43 -20
- data/lib/cucumber/formatter/unicode.rb +1 -0
- data/lib/cucumber/formatter/usage.rb +26 -21
- data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -0
- data/lib/cucumber/gherkin/formatter/escaping.rb +1 -0
- data/lib/cucumber/gherkin/i18n.rb +1 -0
- data/lib/cucumber/gherkin/steps_parser.rb +1 -0
- data/lib/cucumber/hooks.rb +1 -0
- data/lib/cucumber/load_path.rb +1 -0
- data/lib/cucumber/multiline_argument.rb +1 -2
- data/lib/cucumber/multiline_argument/data_table.rb +3 -1
- data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
- data/lib/cucumber/platform.rb +1 -0
- data/lib/cucumber/project_initializer.rb +2 -1
- data/lib/cucumber/rake/task.rb +1 -0
- data/lib/cucumber/rb_support/rb_dsl.rb +11 -9
- data/lib/cucumber/rb_support/rb_hook.rb +1 -0
- data/lib/cucumber/rb_support/rb_language.rb +19 -8
- data/lib/cucumber/rb_support/rb_step_definition.rb +1 -0
- data/lib/cucumber/rb_support/rb_transform.rb +1 -0
- data/lib/cucumber/rb_support/rb_world.rb +42 -20
- data/lib/cucumber/rb_support/snippet.rb +2 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
- data/lib/cucumber/rspec/doubles.rb +1 -0
- data/lib/cucumber/running_test_case.rb +1 -25
- data/lib/cucumber/runtime.rb +15 -10
- data/lib/cucumber/runtime/after_hooks.rb +1 -0
- data/lib/cucumber/runtime/before_hooks.rb +1 -0
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
- data/lib/cucumber/runtime/step_hooks.rb +1 -0
- data/lib/cucumber/runtime/support_code.rb +1 -0
- data/lib/cucumber/runtime/user_interface.rb +1 -0
- data/lib/cucumber/step_argument.rb +1 -0
- data/lib/cucumber/step_definition_light.rb +1 -0
- data/lib/cucumber/step_definitions.rb +1 -0
- data/lib/cucumber/step_match.rb +1 -0
- data/lib/cucumber/step_match_search.rb +1 -0
- data/lib/cucumber/term/ansicolor.rb +1 -0
- data/lib/cucumber/unit.rb +1 -0
- data/lib/cucumber/version +1 -1
- data/lib/simplecov_setup.rb +1 -0
- data/spec/cucumber/cli/configuration_spec.rb +1 -0
- data/spec/cucumber/cli/main_spec.rb +1 -0
- data/spec/cucumber/cli/options_spec.rb +1 -0
- data/spec/cucumber/cli/profile_loader_spec.rb +1 -0
- data/spec/cucumber/cli/rerun_spec.rb +1 -0
- data/spec/cucumber/configuration_spec.rb +1 -0
- data/spec/cucumber/constantize_spec.rb +1 -0
- data/spec/cucumber/core_ext/instance_exec_spec.rb +1 -0
- data/spec/cucumber/file_specs_spec.rb +1 -0
- data/spec/cucumber/filters/activate_steps_spec.rb +9 -6
- data/spec/cucumber/filters/gated_receiver_spec.rb +1 -0
- data/spec/cucumber/filters/retry_spec.rb +27 -21
- data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +1 -0
- data/spec/cucumber/filters/tag_limits/verifier_spec.rb +1 -0
- data/spec/cucumber/filters/tag_limits_spec.rb +1 -0
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -0
- data/spec/cucumber/formatter/console_counts_spec.rb +14 -0
- data/spec/cucumber/formatter/debug_spec.rb +1 -0
- data/spec/cucumber/formatter/duration_spec.rb +1 -0
- data/spec/cucumber/formatter/fail_fast_spec.rb +5 -5
- data/spec/cucumber/formatter/html_spec.rb +6 -1
- data/spec/cucumber/formatter/interceptor_spec.rb +1 -0
- data/spec/cucumber/formatter/json_spec.rb +29 -28
- data/spec/cucumber/formatter/junit_spec.rb +1 -0
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +8 -3
- data/spec/cucumber/formatter/pretty_spec.rb +1 -0
- data/spec/cucumber/formatter/progress_spec.rb +2 -1
- data/spec/cucumber/formatter/rerun_spec.rb +70 -64
- data/spec/cucumber/formatter/spec_helper.rb +8 -7
- data/spec/cucumber/hooks_spec.rb +1 -0
- data/spec/cucumber/multiline_argument/data_table_spec.rb +1 -0
- data/spec/cucumber/project_initializer_spec.rb +2 -1
- data/spec/cucumber/rake/forked_spec.rb +1 -0
- data/spec/cucumber/rake/task_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_language_spec.rb +81 -3
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_transform_spec.rb +1 -0
- data/spec/cucumber/rb_support/rb_world_spec.rb +2 -1
- data/spec/cucumber/rb_support/snippet_spec.rb +1 -0
- data/spec/cucumber/running_test_case_spec.rb +1 -0
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -0
- data/spec/cucumber/runtime/support_code_spec.rb +1 -0
- data/spec/cucumber/runtime_spec.rb +1 -0
- data/spec/cucumber/step_argument_spec.rb +1 -0
- data/spec/cucumber/step_match_search_spec.rb +1 -0
- data/spec/cucumber/step_match_spec.rb +1 -0
- data/spec/cucumber/world/pending_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/standard_step_actions.rb +1 -0
- metadata +24 -23
- data/lib/cucumber/ast.rb +0 -13
- data/lib/cucumber/events/after_test_case.rb +0 -25
- data/lib/cucumber/events/after_test_step.rb +0 -30
- data/lib/cucumber/events/before_test_case.rb +0 -18
- data/lib/cucumber/events/before_test_step.rb +0 -23
- data/lib/cucumber/events/bus.rb +0 -86
- data/lib/cucumber/events/finished_testing.rb +0 -9
- data/lib/cucumber/formatter/event_bus_report.rb +0 -38
- data/spec/cucumber/events/bus_spec.rb +0 -94
- data/spec/cucumber/formatter/event_bus_report_spec.rb +0 -88
- data/spec/cucumber_spec.rb +0 -39
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/constantize'
|
2
3
|
require 'cucumber/cli/rerun_file'
|
3
4
|
require 'cucumber/events'
|
5
|
+
require 'cucumber/core/event_bus'
|
4
6
|
require 'forwardable'
|
5
7
|
require 'cucumber/core/gherkin/tag_expression'
|
8
|
+
require 'cucumber'
|
6
9
|
|
7
10
|
module Cucumber
|
8
11
|
# The base class for configuring settings for a Cucumber run.
|
@@ -20,27 +23,23 @@ module Cucumber
|
|
20
23
|
#
|
21
24
|
# @param event_id [Symbol, Class, String] Identifier for the type of event to subscribe to
|
22
25
|
# @param handler_object [Object optional] an object to be called when the event occurs
|
23
|
-
# @yield [Object] Block to be called when
|
26
|
+
# @yield [Object] Block to be called when the event occurs
|
24
27
|
# @method on_event
|
25
|
-
def_instance_delegator :event_bus, :
|
28
|
+
def_instance_delegator :event_bus, :on, :on_event
|
26
29
|
|
27
30
|
# @private
|
28
|
-
|
31
|
+
def notify(message, *args)
|
32
|
+
event_bus.send(message, *args)
|
33
|
+
end
|
29
34
|
|
30
35
|
def initialize(user_options = {})
|
31
|
-
@options = default_options.merge(
|
36
|
+
@options = default_options.merge(Hash(user_options))
|
32
37
|
end
|
33
38
|
|
34
39
|
def with_options(new_options)
|
35
40
|
self.class.new(@options.merge(new_options))
|
36
41
|
end
|
37
42
|
|
38
|
-
# TODO: Actually Deprecate???
|
39
|
-
def options
|
40
|
-
warn("Deprecated: Configuration#options will be removed from the next release of Cucumber. Please use the configuration object directly instead.")
|
41
|
-
Marshal.load(Marhal.dump(@options))
|
42
|
-
end
|
43
|
-
|
44
43
|
def out_stream
|
45
44
|
@options[:out_stream]
|
46
45
|
end
|
@@ -85,6 +84,30 @@ module Cucumber
|
|
85
84
|
@options[:expand]
|
86
85
|
end
|
87
86
|
|
87
|
+
def source?
|
88
|
+
@options[:source]
|
89
|
+
end
|
90
|
+
|
91
|
+
def duration?
|
92
|
+
@options[:duration]
|
93
|
+
end
|
94
|
+
|
95
|
+
def snippets?
|
96
|
+
@options[:snippets]
|
97
|
+
end
|
98
|
+
|
99
|
+
def skip_profile_information?
|
100
|
+
@options[:skip_profile_information]
|
101
|
+
end
|
102
|
+
|
103
|
+
def profiles
|
104
|
+
@options[:profiles] || []
|
105
|
+
end
|
106
|
+
|
107
|
+
def custom_profiles
|
108
|
+
profiles - [@options[:default_profile]]
|
109
|
+
end
|
110
|
+
|
88
111
|
def paths
|
89
112
|
@options[:paths]
|
90
113
|
end
|
@@ -179,8 +202,7 @@ module Cucumber
|
|
179
202
|
factory = formatter_class(format)
|
180
203
|
yield factory, path_or_io, Cli::Options.new(STDOUT, STDERR, @options)
|
181
204
|
rescue Exception => e
|
182
|
-
e.message
|
183
|
-
raise e
|
205
|
+
raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace
|
184
206
|
end
|
185
207
|
end
|
186
208
|
end
|
@@ -201,7 +223,7 @@ module Cucumber
|
|
201
223
|
# formatter wants to display snippets to the user.
|
202
224
|
#
|
203
225
|
# Each proc should take the following arguments:
|
204
|
-
#
|
226
|
+
#
|
205
227
|
# - keyword
|
206
228
|
# - step text
|
207
229
|
# - multiline argument
|
@@ -216,6 +238,10 @@ module Cucumber
|
|
216
238
|
self
|
217
239
|
end
|
218
240
|
|
241
|
+
def event_bus
|
242
|
+
@options[:event_bus]
|
243
|
+
end
|
244
|
+
|
219
245
|
private
|
220
246
|
|
221
247
|
def default_options
|
@@ -235,15 +261,10 @@ module Cucumber
|
|
235
261
|
:snippets => true,
|
236
262
|
:source => true,
|
237
263
|
:duration => true,
|
238
|
-
:event_bus =>
|
264
|
+
:event_bus => Core::EventBus.new(Core::Events.registry.merge(Cucumber::Events.registry))
|
239
265
|
}
|
240
266
|
end
|
241
267
|
|
242
|
-
def event_bus
|
243
|
-
@options[:event_bus]
|
244
|
-
end
|
245
|
-
|
246
|
-
|
247
268
|
def default_features_paths
|
248
269
|
["features"]
|
249
270
|
end
|
data/lib/cucumber/constantize.rb
CHANGED
data/lib/cucumber/deprecate.rb
CHANGED
data/lib/cucumber/encoding.rb
CHANGED
data/lib/cucumber/errors.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/core/test/result'
|
2
3
|
|
3
4
|
module Cucumber
|
@@ -35,7 +36,8 @@ module Cucumber
|
|
35
36
|
# Raised when a step matches 2 or more StepDefinitions
|
36
37
|
class Ambiguous < StandardError
|
37
38
|
def initialize(step_name, step_definitions, used_guess)
|
38
|
-
message =
|
39
|
+
message = String.new
|
40
|
+
message << "Ambiguous match of \"#{step_name}\":\n\n"
|
39
41
|
message << step_definitions.map{|sd| sd.backtrace_line}.join("\n")
|
40
42
|
message << "\n\n"
|
41
43
|
message << "You can run again with --guess to make Cucumber be more smart about it\n" unless used_guess
|
data/lib/cucumber/events.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
Dir[File.dirname(__FILE__) + '/events/*.rb'].map(&method(:require))
|
3
|
+
|
1
4
|
module Cucumber
|
2
5
|
|
3
6
|
# Events tell you what's happening while Cucumber runs your features.
|
4
7
|
#
|
5
8
|
# They're designed to be read-only, appropriate for writing formatters and other
|
6
|
-
# output tools. If you need to be able to influence the result of a scenario, use a hook instead.
|
9
|
+
# output tools. If you need to be able to influence the result of a scenario, use a {RbSupport::RbDsl hook} instead.
|
7
10
|
#
|
8
11
|
# To subscribe to an event, use {Cucumber::Configuration#on_event}
|
9
12
|
#
|
10
13
|
# @example
|
11
14
|
# AfterConfiguration do |config|
|
12
|
-
# config.on_event :
|
15
|
+
# config.on_event :test_case_finished do |event|
|
13
16
|
# puts event.result
|
14
17
|
# end
|
15
18
|
# end
|
19
|
+
#
|
16
20
|
module Events
|
21
|
+
def self.registry
|
22
|
+
Core::Events.build_registry(
|
23
|
+
StepDefinitionRegistered,
|
24
|
+
StepMatch,
|
25
|
+
TestRunFinished,
|
26
|
+
)
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
19
30
|
|
20
|
-
Dir[File.dirname(__FILE__) + '/events/*.rb'].map(&method(:require))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cucumber/core/events'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Events
|
6
|
+
|
7
|
+
# Event fired after each step definition has been registered
|
8
|
+
class StepDefinitionRegistered < Core::Event.new(:step_definition)
|
9
|
+
|
10
|
+
|
11
|
+
#_The step definition that was just registered.
|
12
|
+
#
|
13
|
+
# @return [Cucumber::Core::Test::Case]
|
14
|
+
attr_reader :step_definition
|
15
|
+
|
16
|
+
#_@private
|
17
|
+
def initialize(step_definition)
|
18
|
+
@step_definition = step_definition
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cucumber/core/events'
|
3
|
+
|
1
4
|
module Cucumber
|
2
5
|
module Events
|
3
6
|
|
4
7
|
# Event fired when a step is matched to a definition
|
5
|
-
class StepMatch
|
8
|
+
class StepMatch < Core::Event.new(:test_step, :step_match)
|
6
9
|
|
7
10
|
# The test step that was matched.
|
8
11
|
#
|
data/lib/cucumber/file_specs.rb
CHANGED
data/lib/cucumber/filters.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/filters/activate_steps'
|
2
3
|
require 'cucumber/filters/apply_after_step_hooks'
|
3
4
|
require 'cucumber/filters/apply_before_hooks'
|
@@ -6,4 +7,5 @@ require 'cucumber/filters/apply_around_hooks'
|
|
6
7
|
require 'cucumber/filters/prepare_world'
|
7
8
|
require 'cucumber/filters/quit'
|
8
9
|
require 'cucumber/filters/randomizer'
|
10
|
+
require 'cucumber/filters/retry'
|
9
11
|
require 'cucumber/filters/tag_limits'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/core/filter'
|
2
3
|
require 'cucumber/step_match'
|
3
4
|
require 'cucumber/events'
|
@@ -43,7 +44,7 @@ module Cucumber
|
|
43
44
|
|
44
45
|
def result
|
45
46
|
return NoStepMatch.new(test_step.source.last, test_step.name) unless matches.any?
|
46
|
-
configuration.notify
|
47
|
+
configuration.notify :step_match, test_step, match
|
47
48
|
return SkippingStepMatch.new if configuration.dry_run?
|
48
49
|
match
|
49
50
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/core/filter'
|
2
3
|
require 'cucumber/running_test_case'
|
3
|
-
require 'cucumber/events
|
4
|
-
require 'cucumber/events/after_test_case'
|
4
|
+
require 'cucumber/events'
|
5
5
|
|
6
6
|
module Cucumber
|
7
7
|
module Filters
|
8
8
|
class Retry < Core::Filter.new(:configuration)
|
9
9
|
|
10
10
|
def test_case(test_case)
|
11
|
-
configuration.on_event(:
|
11
|
+
configuration.on_event(:test_case_finished) do |event|
|
12
12
|
next unless retry_required?(test_case, event)
|
13
13
|
|
14
14
|
test_case_counts[test_case] += 1
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/platform'
|
2
3
|
|
3
4
|
|
@@ -19,9 +20,9 @@ module Cucumber
|
|
19
20
|
return @exception if ::Cucumber.use_full_backtrace
|
20
21
|
|
21
22
|
pwd_pattern = /#{::Regexp.escape(::Dir.pwd)}\//m
|
22
|
-
@exception.backtrace.
|
23
|
+
backtrace = @exception.backtrace.map { |line| line.gsub(pwd_pattern, "./") }
|
23
24
|
|
24
|
-
filtered = (
|
25
|
+
filtered = (backtrace || []).reject do |line|
|
25
26
|
BACKTRACE_FILTER_PATTERNS.detect { |p| line =~ p }
|
26
27
|
end
|
27
28
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/formatter/ansicolor'
|
2
3
|
require 'cucumber/formatter/duration'
|
3
|
-
require 'cucumber/
|
4
|
+
require 'cucumber/gherkin/i18n'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module Formatter
|
@@ -28,7 +29,6 @@ module Cucumber
|
|
28
29
|
module Console
|
29
30
|
extend ANSIColor
|
30
31
|
include Duration
|
31
|
-
include Summary
|
32
32
|
|
33
33
|
def format_step(keyword, step_match, status, source_indent)
|
34
34
|
comment = if source_indent
|
@@ -59,75 +59,53 @@ module Cucumber
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def print_elements(elements, status, kind)
|
62
|
-
if elements.
|
62
|
+
return if elements.empty?
|
63
|
+
|
64
|
+
element_messages = element_messages(elements, status)
|
65
|
+
print_element_messages(element_messages, status, kind)
|
66
|
+
end
|
67
|
+
|
68
|
+
def print_element_messages(element_messages, status, kind)
|
69
|
+
if element_messages.any?
|
63
70
|
@io.puts(format_string("(::) #{status} #{kind} (::)", status))
|
64
71
|
@io.puts
|
65
72
|
@io.flush
|
66
73
|
end
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
print_exception(element.exception, status, 0)
|
71
|
-
else
|
72
|
-
message = linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
|
73
|
-
@io.puts(format_string(message, status))
|
74
|
-
end
|
75
|
+
element_messages.each do |message|
|
76
|
+
@io.puts(format_string(message, status))
|
75
77
|
@io.puts
|
76
78
|
@io.flush
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
def print_statistics(duration, options)
|
86
|
-
failures = collect_failing_scenarios(runtime)
|
87
|
-
if !failures.empty?
|
88
|
-
print_failing_scenarios(failures, options.custom_profiles, options[:source])
|
82
|
+
def print_statistics(duration, config, counts, issues)
|
83
|
+
if issues.any?
|
84
|
+
@io.puts issues.to_s
|
85
|
+
@io.puts
|
89
86
|
end
|
90
87
|
|
91
|
-
@io.puts
|
92
|
-
@io.puts
|
93
|
-
@io.puts(format_duration(duration)) if duration && options[:duration]
|
88
|
+
@io.puts counts.to_s
|
89
|
+
@io.puts(format_duration(duration)) if duration && config.duration?
|
94
90
|
|
95
|
-
if
|
91
|
+
if config.randomize?
|
96
92
|
@io.puts
|
97
|
-
@io.puts "Randomized with seed #{
|
93
|
+
@io.puts "Randomized with seed #{config.seed}"
|
98
94
|
end
|
99
95
|
|
100
96
|
@io.flush
|
101
97
|
end
|
102
98
|
|
103
|
-
def
|
104
|
-
|
105
|
-
|
106
|
-
example_table_class = Core::Ast::ExamplesTable
|
107
|
-
|
108
|
-
runtime.scenarios(:failed).select do |s|
|
109
|
-
[scenario_class, example_table_class].include?(s.class)
|
110
|
-
end.map do |s|
|
111
|
-
s.is_a?(example_table_class)? s.scenario_outline : s
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def print_failing_scenarios(failures, custom_profiles, given_source)
|
116
|
-
@io.puts format_string("Failing Scenarios:", :failed)
|
117
|
-
failures.each do |failure|
|
118
|
-
profiles_string = custom_profiles.empty? ? '' : (custom_profiles.map{|profile| "-p #{profile}" }).join(' ') + ' '
|
119
|
-
source = given_source ? format_string(" # " + failure.name, :comment) : ''
|
120
|
-
@io.puts format_string("cucumber #{profiles_string}" + failure.location, :failed) + source
|
121
|
-
end
|
122
|
-
@io.puts
|
99
|
+
def print_exception(e, status, indent)
|
100
|
+
string = exception_message_string(e, indent)
|
101
|
+
@io.puts(format_string(string, status))
|
123
102
|
end
|
124
103
|
|
125
|
-
def
|
126
|
-
message = "#{e.message} (#{e.class})".force_encoding("UTF-8")
|
104
|
+
def exception_message_string(e, indent)
|
105
|
+
message = "#{e.message} (#{e.class})".dup.force_encoding("UTF-8")
|
127
106
|
message = linebreaks(message, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
|
128
107
|
|
129
108
|
string = "#{message}\n#{e.backtrace.join("\n")}".indent(indent)
|
130
|
-
@io.puts(format_string(string, status))
|
131
109
|
end
|
132
110
|
|
133
111
|
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10655
|
@@ -151,8 +129,15 @@ module Cucumber
|
|
151
129
|
return unless options[:snippets]
|
152
130
|
return if runtime.steps(:undefined).empty?
|
153
131
|
|
132
|
+
snippet_text_proc = lambda { |step_keyword, step_name, multiline_arg|
|
133
|
+
runtime.snippet_text(step_keyword, step_name, multiline_arg)
|
134
|
+
}
|
135
|
+
do_print_snippets(snippet_text_proc)
|
136
|
+
end
|
137
|
+
|
138
|
+
def do_print_snippets(snippet_text_proc)
|
154
139
|
snippets = @snippets_input.map do |data|
|
155
|
-
|
140
|
+
snippet_text_proc.call(data.actual_keyword, data.step.name, data.step.multiline_arg)
|
156
141
|
end.uniq
|
157
142
|
|
158
143
|
text = "\nYou can implement step definitions for undefined steps with these snippets:\n\n"
|
@@ -165,10 +150,14 @@ module Cucumber
|
|
165
150
|
|
166
151
|
def print_passing_wip(options)
|
167
152
|
return unless options[:wip]
|
168
|
-
|
169
|
-
|
153
|
+
passed_messages = element_messages(runtime.scenarios(:passed), :passed)
|
154
|
+
do_print_passing_wip(passed_messages)
|
155
|
+
end
|
156
|
+
|
157
|
+
def do_print_passing_wip(passed_messages)
|
158
|
+
if passed_messages.any?
|
170
159
|
@io.puts format_string("\nThe --wip switch was used, so I didn't expect anything to pass. These scenarios passed:", :failed)
|
171
|
-
|
160
|
+
print_element_messages(passed_messages, :passed, "scenarios")
|
172
161
|
else
|
173
162
|
@io.puts format_string("\nThe --wip switch was used, so the failures were expected. All is good.\n", :passed)
|
174
163
|
end
|
@@ -217,7 +206,10 @@ module Cucumber
|
|
217
206
|
|
218
207
|
def print_profile_information
|
219
208
|
return if @options[:skip_profile_information] || @options[:profiles].nil? || @options[:profiles].empty?
|
220
|
-
|
209
|
+
do_print_profile_information(@options[:profiles])
|
210
|
+
end
|
211
|
+
|
212
|
+
def do_print_profile_information(profiles)
|
221
213
|
profiles_sentence = ''
|
222
214
|
profiles_sentence = profiles.size == 1 ? profiles.first :
|
223
215
|
"#{profiles[0...-1].join(', ')} and #{profiles.last}"
|
@@ -240,6 +232,23 @@ module Cucumber
|
|
240
232
|
not test_step.source.last.respond_to?(:actual_keyword)
|
241
233
|
end
|
242
234
|
|
235
|
+
def element_messages(elements, status)
|
236
|
+
element_messages = elements.map do |element|
|
237
|
+
if status == :failed
|
238
|
+
message = exception_message_string(element.exception, 0)
|
239
|
+
else
|
240
|
+
message = linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def snippet_text(step_keyword, step_name, multiline_arg)
|
246
|
+
keyword = Cucumber::Gherkin::I18n.code_keyword_for(step_keyword).strip
|
247
|
+
config.snippet_generators.map { |generator|
|
248
|
+
generator.call(keyword, step_name, multiline_arg, config.snippet_type)
|
249
|
+
}.join("\n")
|
250
|
+
end
|
251
|
+
|
243
252
|
class SnippetData
|
244
253
|
attr_reader :actual_keyword, :step
|
245
254
|
def initialize(actual_keyword, step)
|