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,4 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cucumber/core/report/summary'
|
3
|
+
require 'cucumber/formatter/backtrace_filter'
|
1
4
|
require 'cucumber/formatter/console'
|
5
|
+
require 'cucumber/formatter/console_counts'
|
6
|
+
require 'cucumber/formatter/console_issues'
|
2
7
|
require 'cucumber/formatter/io'
|
3
8
|
require 'cucumber/formatter/duration_extractor'
|
4
9
|
require 'cucumber/formatter/hook_query_visitor'
|
@@ -10,32 +15,60 @@ module Cucumber
|
|
10
15
|
include Console
|
11
16
|
include Io
|
12
17
|
attr_reader :runtime
|
18
|
+
attr_reader :config, :summary
|
13
19
|
|
14
|
-
def initialize(
|
15
|
-
@
|
20
|
+
def initialize(config)
|
21
|
+
@config, @io = config, ensure_io(config.out_stream)
|
16
22
|
@previous_step_keyword = nil
|
17
23
|
@snippets_input = []
|
18
24
|
@total_duration = 0
|
25
|
+
@summary = Cucumber::Core::Report::Summary.new(config.event_bus)
|
26
|
+
@matches = {}
|
27
|
+
@pending_step_matches = []
|
28
|
+
@failed_results = []
|
29
|
+
@failed_test_cases = []
|
30
|
+
@passed_test_cases = []
|
31
|
+
@counts = ConsoleCounts.new(config)
|
32
|
+
@issues = ConsoleIssues.new(config)
|
33
|
+
config.on_event :step_match, &method(:on_step_match)
|
34
|
+
config.on_event :test_case_starting, &method(:on_test_case_starting)
|
35
|
+
config.on_event :test_step_finished, &method(:on_test_step_finished)
|
36
|
+
config.on_event :test_case_finished, &method(:on_test_case_finished)
|
37
|
+
config.on_event :test_run_finished, &method(:on_test_run_finished)
|
19
38
|
end
|
20
39
|
|
21
|
-
def
|
40
|
+
def on_step_match(event)
|
41
|
+
@matches[event.test_step.source] = event.step_match
|
42
|
+
end
|
43
|
+
|
44
|
+
def on_test_case_starting(_event)
|
22
45
|
unless @profile_information_printed
|
23
|
-
|
46
|
+
do_print_profile_information(config.profiles) unless config.skip_profile_information? || config.profiles.nil? || config.profiles.empty?
|
24
47
|
@profile_information_printed = true
|
25
48
|
end
|
26
49
|
@previous_step_keyword = nil
|
27
50
|
end
|
28
51
|
|
29
|
-
def
|
52
|
+
def on_test_step_finished(event)
|
53
|
+
test_step = event.test_step
|
54
|
+
result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
30
55
|
progress(result.to_sym) if !HookQueryVisitor.new(test_step).hook? || result.failed?
|
31
|
-
|
56
|
+
unless HookQueryVisitor.new(test_step).hook?
|
57
|
+
collect_snippet_data(test_step, result)
|
58
|
+
@pending_step_matches << @matches[test_step.source] if result.pending?
|
59
|
+
@failed_results << result if result.failed?
|
60
|
+
end
|
32
61
|
end
|
33
62
|
|
34
|
-
def
|
63
|
+
def on_test_case_finished(event)
|
64
|
+
test_case = event.test_case
|
65
|
+
result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
66
|
+
@failed_test_cases << test_case if result.failed?
|
67
|
+
@passed_test_cases << test_case if result.passed?
|
35
68
|
@total_duration += DurationExtractor.new(result).result_duration
|
36
69
|
end
|
37
70
|
|
38
|
-
def
|
71
|
+
def on_test_run_finished(_event)
|
39
72
|
@io.puts
|
40
73
|
@io.puts
|
41
74
|
print_summary
|
@@ -44,11 +77,19 @@ module Cucumber
|
|
44
77
|
private
|
45
78
|
|
46
79
|
def print_summary
|
47
|
-
|
48
|
-
|
49
|
-
print_statistics(@total_duration, @
|
50
|
-
|
51
|
-
|
80
|
+
print_elements(@pending_step_matches, :pending, 'steps')
|
81
|
+
print_elements(@failed_results, :failed, 'steps')
|
82
|
+
print_statistics(@total_duration, @config, @counts, @issues)
|
83
|
+
snippet_text_proc = lambda { |step_keyword, step_name, multiline_arg|
|
84
|
+
snippet_text(step_keyword, step_name, multiline_arg)
|
85
|
+
}
|
86
|
+
do_print_snippets(snippet_text_proc) if config.snippets? && summary.test_steps.total(:undefined) > 0
|
87
|
+
if config.wip?
|
88
|
+
messages = @passed_test_cases.map do |test_case|
|
89
|
+
message = linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
|
90
|
+
end
|
91
|
+
do_print_passing_wip(messages)
|
92
|
+
end
|
52
93
|
end
|
53
94
|
|
54
95
|
CHARS = {
|
@@ -68,6 +109,8 @@ module Cucumber
|
|
68
109
|
def table_header_cell?(status)
|
69
110
|
status == :skipped_param
|
70
111
|
end
|
112
|
+
|
113
|
+
TestCaseData = Struct.new(:name, :location)
|
71
114
|
end
|
72
115
|
end
|
73
116
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/formatter/io'
|
2
3
|
|
3
4
|
module Cucumber
|
@@ -5,28 +6,24 @@ module Cucumber
|
|
5
6
|
class Rerun
|
6
7
|
include Formatter::Io
|
7
8
|
|
8
|
-
def initialize(
|
9
|
-
@io = ensure_io(
|
9
|
+
def initialize(config)
|
10
|
+
@io = ensure_io(config.out_stream)
|
11
|
+
@config = config
|
10
12
|
@failures = {}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return if @failures.empty?
|
22
|
-
@io.print file_failures.join(' ')
|
23
|
-
end
|
24
|
-
|
25
|
-
[:before_test_case, :before_test_step, :after_test_step].each do |method|
|
26
|
-
define_method(method) { |*| }
|
13
|
+
config.on_event :test_case_finished do |event|
|
14
|
+
test_case, result = *event.attributes
|
15
|
+
next if result.ok?(@config.strict?)
|
16
|
+
@failures[test_case.location.file] ||= []
|
17
|
+
@failures[test_case.location.file] << test_case.location.line
|
18
|
+
end
|
19
|
+
config.on_event :test_run_finished do
|
20
|
+
next if @failures.empty?
|
21
|
+
@io.print file_failures.join(' ')
|
22
|
+
end
|
27
23
|
end
|
28
24
|
|
29
25
|
private
|
26
|
+
|
30
27
|
def file_failures
|
31
28
|
@failures.map { |file, lines| [file, lines].join(':') }
|
32
29
|
end
|
@@ -1,35 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cucumber/formatter/io'
|
3
|
+
require 'cucumber/formatter/console'
|
4
|
+
require 'cucumber/formatter/console_counts'
|
5
|
+
require 'cucumber/formatter/console_issues'
|
6
|
+
require 'cucumber/core/test/result'
|
7
|
+
|
1
8
|
module Cucumber
|
2
9
|
module Formatter
|
3
|
-
module Summary
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
# Summary formatter, outputting only feature / scenario titles
|
12
|
+
class Summary
|
13
|
+
include Io
|
14
|
+
include Console
|
15
|
+
|
16
|
+
def initialize(config)
|
17
|
+
@config, @io = config, ensure_io(config.out_stream)
|
18
|
+
@counts = ConsoleCounts.new(@config)
|
19
|
+
@issues = ConsoleIssues.new(@config)
|
20
|
+
@start_time = Time.now
|
9
21
|
|
10
|
-
|
11
|
-
|
12
|
-
|
22
|
+
@config.on_event :test_case_starting do |event|
|
23
|
+
print_feature event.test_case
|
24
|
+
print_test_case event.test_case
|
25
|
+
end
|
26
|
+
|
27
|
+
@config.on_event :test_case_finished do |event|
|
28
|
+
print_result event.result
|
29
|
+
end
|
30
|
+
|
31
|
+
@config.on_event :test_run_finished do |event|
|
32
|
+
duration = Time.now - @start_time
|
33
|
+
@io.puts
|
34
|
+
print_statistics(duration, @config, @counts, @issues)
|
35
|
+
end
|
13
36
|
end
|
14
37
|
|
15
38
|
private
|
16
39
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
" (#{counts.join(', ')})"
|
24
|
-
else
|
25
|
-
""
|
26
|
-
end
|
40
|
+
def print_feature(test_case)
|
41
|
+
feature = test_case.feature
|
42
|
+
return if @current_feature == feature
|
43
|
+
@io.puts unless @current_feature.nil?
|
44
|
+
@io.puts feature
|
45
|
+
@current_feature = feature
|
27
46
|
end
|
28
47
|
|
29
|
-
def
|
30
|
-
|
48
|
+
def print_test_case(test_case)
|
49
|
+
@io.print " #{test_case.name} "
|
31
50
|
end
|
32
51
|
|
52
|
+
def print_result(result)
|
53
|
+
@io.puts format_string(result, result.to_sym)
|
54
|
+
end
|
33
55
|
end
|
34
56
|
end
|
35
57
|
end
|
58
|
+
|
@@ -1,30 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'cucumber/formatter/progress'
|
2
3
|
require 'cucumber/step_definition_light'
|
3
4
|
|
4
5
|
module Cucumber
|
5
6
|
module Formatter
|
6
7
|
class Usage < Progress
|
7
|
-
include Console
|
8
8
|
|
9
9
|
class StepDefKey < StepDefinitionLight
|
10
10
|
attr_accessor :mean_duration, :status
|
11
11
|
end
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
|
15
|
-
@io = ensure_io(path_or_io)
|
16
|
-
@options = options
|
13
|
+
def initialize(config)
|
14
|
+
super
|
17
15
|
@stepdef_to_match = Hash.new { |h, stepdef_key| h[stepdef_key] = [] }
|
18
16
|
@total_duration = 0
|
19
17
|
@matches = {}
|
20
|
-
|
21
|
-
|
18
|
+
config.on_event :step_match do |event|
|
19
|
+
test_step, step_match = *event.attributes
|
20
|
+
@matches[test_step.source] = step_match
|
22
21
|
end
|
22
|
+
config.on_event :step_definition_registered, &method(:on_step_definition_registered)
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_step_definition_registered(event)
|
26
|
+
stepdef_key = StepDefKey.new(event.step_definition.regexp_source, event.step_definition.location)
|
27
|
+
@stepdef_to_match[stepdef_key] = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_step_match(event)
|
31
|
+
@matches[event.test_step.source] = event.step_match
|
32
|
+
super
|
23
33
|
end
|
24
34
|
|
25
|
-
def
|
26
|
-
return if HookQueryVisitor.new(test_step).hook?
|
35
|
+
def on_test_step_finished(event)
|
36
|
+
return if HookQueryVisitor.new(event.test_step).hook?
|
27
37
|
|
38
|
+
test_step = event.test_step
|
39
|
+
result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
28
40
|
step_match = @matches[test_step.source]
|
29
41
|
step_definition = step_match.step_definition
|
30
42
|
stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.location)
|
@@ -45,10 +57,9 @@ module Cucumber
|
|
45
57
|
private
|
46
58
|
|
47
59
|
def print_summary
|
48
|
-
add_unused_stepdefs
|
49
60
|
aggregate_info
|
50
61
|
|
51
|
-
if
|
62
|
+
if config.dry_run?
|
52
63
|
keys = @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source}
|
53
64
|
else
|
54
65
|
keys = @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse
|
@@ -68,9 +79,9 @@ module Cucumber
|
|
68
79
|
end
|
69
80
|
|
70
81
|
def print_step_definition(stepdef_key)
|
71
|
-
@io.print format_string(sprintf("%.7f", stepdef_key.mean_duration), :skipped) + " " unless
|
82
|
+
@io.print format_string(sprintf("%.7f", stepdef_key.mean_duration), :skipped) + " " unless config.dry_run?
|
72
83
|
@io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
|
73
|
-
if
|
84
|
+
if config.source?
|
74
85
|
indent = max_length - stepdef_key.regexp_source.unpack('U*').length
|
75
86
|
line_comment = " # #{stepdef_key.location}".indent(indent)
|
76
87
|
@io.print(format_string(line_comment, :comment))
|
@@ -81,9 +92,9 @@ module Cucumber
|
|
81
92
|
def print_steps(stepdef_key)
|
82
93
|
@stepdef_to_match[stepdef_key].each do |step|
|
83
94
|
@io.print " "
|
84
|
-
@io.print format_string(sprintf("%.7f", step[:duration]), :skipped) + " " unless
|
95
|
+
@io.print format_string(sprintf("%.7f", step[:duration]), :skipped) + " " unless config.dry_run?
|
85
96
|
@io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
|
86
|
-
if
|
97
|
+
if config.source?
|
87
98
|
indent = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
|
88
99
|
line_comment = " # #{step[:location]}".indent(indent)
|
89
100
|
@io.print(format_string(line_comment, :comment))
|
@@ -125,12 +136,6 @@ module Cucumber
|
|
125
136
|
end
|
126
137
|
end
|
127
138
|
|
128
|
-
def add_unused_stepdefs
|
129
|
-
@runtime.unmatched_step_definitions.each do |step_definition|
|
130
|
-
stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.location)
|
131
|
-
@stepdef_to_match[stepdef_key] = []
|
132
|
-
end
|
133
|
-
end
|
134
139
|
end
|
135
140
|
end
|
136
141
|
end
|
data/lib/cucumber/hooks.rb
CHANGED
data/lib/cucumber/load_path.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'forwardable'
|
2
3
|
require 'cucumber/gherkin/data_table_parser'
|
3
4
|
require 'cucumber/gherkin/formatter/escaping'
|
@@ -469,7 +470,8 @@ module Cucumber
|
|
469
470
|
|
470
471
|
c = Cucumber::Term::ANSIColor.coloring?
|
471
472
|
Cucumber::Term::ANSIColor.coloring = options[:color]
|
472
|
-
|
473
|
+
runtime = Struct.new(:configuration).new(Configuration.new)
|
474
|
+
formatter = Formatter::Pretty.new(runtime, io, options)
|
473
475
|
formatter.instance_variable_set('@indent', options[:indent])
|
474
476
|
Formatter::LegacyApi::Ast::MultilineArg.for(self).accept(Formatter::Fanout.new([formatter]))
|
475
477
|
Cucumber::Term::ANSIColor.coloring = c
|
data/lib/cucumber/platform.rb
CHANGED
data/lib/cucumber/rake/task.rb
CHANGED