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.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -10
  3. data/CONTRIBUTING.md +13 -0
  4. data/Gemfile +11 -4
  5. data/History.md +19 -1
  6. data/README.md +1 -1
  7. data/cucumber.gemspec +2 -2
  8. data/cucumber.yml +2 -2
  9. data/features/docs/api/listen_for_events.feature +7 -6
  10. data/features/docs/cli/help.feature +8 -0
  11. data/features/docs/cli/retry_failing_tests.feature +51 -16
  12. data/features/docs/defining_steps/nested_steps_i18n.feature +2 -0
  13. data/features/docs/defining_steps/printing_messages.feature +0 -1
  14. data/features/docs/defining_steps/skip_scenario.feature +0 -34
  15. data/features/docs/extending_cucumber/custom_formatter.feature +2 -30
  16. data/features/docs/formatters/summary_formatter.feature +34 -0
  17. data/features/docs/gherkin/unicode_table.feature +1 -1
  18. data/features/docs/post_configuration_hook.feature +0 -16
  19. data/features/docs/writing_support_code/world.feature +129 -0
  20. data/features/lib/step_definitions/aruba_steps.rb +1 -0
  21. data/features/lib/step_definitions/cli_steps.rb +4 -0
  22. data/features/lib/step_definitions/cucumber_steps.rb +1 -0
  23. data/features/lib/step_definitions/iso-8859-1_steps.rb +1 -0
  24. data/features/lib/step_definitions/json_steps.rb +1 -0
  25. data/features/lib/step_definitions/junit_steps.rb +1 -0
  26. data/features/lib/step_definitions/language_steps.rb +1 -0
  27. data/features/lib/step_definitions/profile_steps.rb +1 -0
  28. data/features/lib/step_definitions/retry_steps.rb +32 -12
  29. data/features/lib/step_definitions/ruby_steps.rb +1 -0
  30. data/features/lib/step_definitions/wire_steps.rb +1 -0
  31. data/features/lib/support/env.rb +2 -1
  32. data/features/lib/support/fake_wire_server.rb +1 -0
  33. data/features/lib/support/feature_factory.rb +1 -0
  34. data/features/lib/support/normalise_output.rb +1 -0
  35. data/gem_tasks/contributors.rake +1 -0
  36. data/gem_tasks/cov.rake +1 -0
  37. data/gem_tasks/cucumber.rake +1 -0
  38. data/gem_tasks/downloads.rb +1 -0
  39. data/gem_tasks/environment.rake +1 -0
  40. data/gem_tasks/examples.rake +2 -1
  41. data/gem_tasks/fix_cr_lf.rake +2 -1
  42. data/gem_tasks/flog.rake +2 -1
  43. data/gem_tasks/rspec.rake +1 -0
  44. data/gem_tasks/sass.rake +2 -1
  45. data/lib/autotest/cucumber.rb +1 -0
  46. data/lib/autotest/cucumber_mixin.rb +1 -0
  47. data/lib/autotest/cucumber_rails.rb +1 -0
  48. data/lib/autotest/cucumber_rails_rspec.rb +1 -0
  49. data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
  50. data/lib/autotest/cucumber_rspec.rb +1 -0
  51. data/lib/autotest/cucumber_rspec2.rb +1 -0
  52. data/lib/autotest/discover.rb +1 -0
  53. data/lib/cucumber.rb +1 -13
  54. data/lib/cucumber/cli/configuration.rb +3 -6
  55. data/lib/cucumber/cli/main.rb +2 -1
  56. data/lib/cucumber/cli/options.rb +239 -173
  57. data/lib/cucumber/cli/profile_loader.rb +1 -0
  58. data/lib/cucumber/cli/rerun_file.rb +1 -0
  59. data/lib/cucumber/configuration.rb +40 -19
  60. data/lib/cucumber/constantize.rb +1 -0
  61. data/lib/cucumber/core_ext/instance_exec.rb +1 -0
  62. data/lib/cucumber/core_ext/string.rb +1 -0
  63. data/lib/cucumber/deprecate.rb +1 -0
  64. data/lib/cucumber/encoding.rb +1 -0
  65. data/lib/cucumber/errors.rb +3 -1
  66. data/lib/cucumber/events.rb +13 -3
  67. data/lib/cucumber/events/step_definition_registered.rb +24 -0
  68. data/lib/cucumber/events/step_match.rb +4 -1
  69. data/lib/cucumber/events/test_run_finished.rb +12 -0
  70. data/lib/cucumber/file_specs.rb +1 -0
  71. data/lib/cucumber/filters.rb +2 -0
  72. data/lib/cucumber/filters/activate_steps.rb +2 -1
  73. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  74. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  75. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  76. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  77. data/lib/cucumber/filters/gated_receiver.rb +1 -0
  78. data/lib/cucumber/filters/prepare_world.rb +1 -0
  79. data/lib/cucumber/filters/quit.rb +1 -0
  80. data/lib/cucumber/filters/randomizer.rb +1 -0
  81. data/lib/cucumber/filters/retry.rb +3 -3
  82. data/lib/cucumber/filters/tag_limits.rb +1 -0
  83. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -0
  84. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -0
  85. data/lib/cucumber/formatter/ansicolor.rb +1 -0
  86. data/lib/cucumber/formatter/backtrace_filter.rb +3 -2
  87. data/lib/cucumber/formatter/console.rb +61 -52
  88. data/lib/cucumber/formatter/console_counts.rb +57 -0
  89. data/lib/cucumber/formatter/console_issues.rb +37 -0
  90. data/lib/cucumber/formatter/debug.rb +1 -0
  91. data/lib/cucumber/formatter/duration.rb +1 -0
  92. data/lib/cucumber/formatter/duration_extractor.rb +1 -0
  93. data/lib/cucumber/formatter/fail_fast.rb +4 -2
  94. data/lib/cucumber/formatter/fanout.rb +1 -0
  95. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  96. data/lib/cucumber/formatter/html.rb +6 -5
  97. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -0
  98. data/lib/cucumber/formatter/interceptor.rb +1 -0
  99. data/lib/cucumber/formatter/io.rb +1 -0
  100. data/lib/cucumber/formatter/json.rb +15 -13
  101. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  102. data/lib/cucumber/formatter/junit.rb +13 -11
  103. data/lib/cucumber/formatter/legacy_api/adapter.rb +28 -32
  104. data/lib/cucumber/formatter/legacy_api/ast.rb +1 -0
  105. data/lib/cucumber/formatter/legacy_api/results.rb +1 -0
  106. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +1 -0
  107. data/lib/cucumber/formatter/pretty.rb +7 -1
  108. data/lib/cucumber/formatter/progress.rb +56 -13
  109. data/lib/cucumber/formatter/rerun.rb +15 -18
  110. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  111. data/lib/cucumber/formatter/steps.rb +1 -0
  112. data/lib/cucumber/formatter/summary.rb +43 -20
  113. data/lib/cucumber/formatter/unicode.rb +1 -0
  114. data/lib/cucumber/formatter/usage.rb +26 -21
  115. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  116. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -0
  117. data/lib/cucumber/gherkin/formatter/escaping.rb +1 -0
  118. data/lib/cucumber/gherkin/i18n.rb +1 -0
  119. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  120. data/lib/cucumber/hooks.rb +1 -0
  121. data/lib/cucumber/load_path.rb +1 -0
  122. data/lib/cucumber/multiline_argument.rb +1 -2
  123. data/lib/cucumber/multiline_argument/data_table.rb +3 -1
  124. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  125. data/lib/cucumber/platform.rb +1 -0
  126. data/lib/cucumber/project_initializer.rb +2 -1
  127. data/lib/cucumber/rake/task.rb +1 -0
  128. data/lib/cucumber/rb_support/rb_dsl.rb +11 -9
  129. data/lib/cucumber/rb_support/rb_hook.rb +1 -0
  130. data/lib/cucumber/rb_support/rb_language.rb +19 -8
  131. data/lib/cucumber/rb_support/rb_step_definition.rb +1 -0
  132. data/lib/cucumber/rb_support/rb_transform.rb +1 -0
  133. data/lib/cucumber/rb_support/rb_world.rb +42 -20
  134. data/lib/cucumber/rb_support/snippet.rb +2 -1
  135. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  136. data/lib/cucumber/rspec/doubles.rb +1 -0
  137. data/lib/cucumber/running_test_case.rb +1 -25
  138. data/lib/cucumber/runtime.rb +15 -10
  139. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  140. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  141. data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
  142. data/lib/cucumber/runtime/step_hooks.rb +1 -0
  143. data/lib/cucumber/runtime/support_code.rb +1 -0
  144. data/lib/cucumber/runtime/user_interface.rb +1 -0
  145. data/lib/cucumber/step_argument.rb +1 -0
  146. data/lib/cucumber/step_definition_light.rb +1 -0
  147. data/lib/cucumber/step_definitions.rb +1 -0
  148. data/lib/cucumber/step_match.rb +1 -0
  149. data/lib/cucumber/step_match_search.rb +1 -0
  150. data/lib/cucumber/term/ansicolor.rb +1 -0
  151. data/lib/cucumber/unit.rb +1 -0
  152. data/lib/cucumber/version +1 -1
  153. data/lib/simplecov_setup.rb +1 -0
  154. data/spec/cucumber/cli/configuration_spec.rb +1 -0
  155. data/spec/cucumber/cli/main_spec.rb +1 -0
  156. data/spec/cucumber/cli/options_spec.rb +1 -0
  157. data/spec/cucumber/cli/profile_loader_spec.rb +1 -0
  158. data/spec/cucumber/cli/rerun_spec.rb +1 -0
  159. data/spec/cucumber/configuration_spec.rb +1 -0
  160. data/spec/cucumber/constantize_spec.rb +1 -0
  161. data/spec/cucumber/core_ext/instance_exec_spec.rb +1 -0
  162. data/spec/cucumber/file_specs_spec.rb +1 -0
  163. data/spec/cucumber/filters/activate_steps_spec.rb +9 -6
  164. data/spec/cucumber/filters/gated_receiver_spec.rb +1 -0
  165. data/spec/cucumber/filters/retry_spec.rb +27 -21
  166. data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +1 -0
  167. data/spec/cucumber/filters/tag_limits/verifier_spec.rb +1 -0
  168. data/spec/cucumber/filters/tag_limits_spec.rb +1 -0
  169. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -0
  170. data/spec/cucumber/formatter/console_counts_spec.rb +14 -0
  171. data/spec/cucumber/formatter/debug_spec.rb +1 -0
  172. data/spec/cucumber/formatter/duration_spec.rb +1 -0
  173. data/spec/cucumber/formatter/fail_fast_spec.rb +5 -5
  174. data/spec/cucumber/formatter/html_spec.rb +6 -1
  175. data/spec/cucumber/formatter/interceptor_spec.rb +1 -0
  176. data/spec/cucumber/formatter/json_spec.rb +29 -28
  177. data/spec/cucumber/formatter/junit_spec.rb +1 -0
  178. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +8 -3
  179. data/spec/cucumber/formatter/pretty_spec.rb +1 -0
  180. data/spec/cucumber/formatter/progress_spec.rb +2 -1
  181. data/spec/cucumber/formatter/rerun_spec.rb +70 -64
  182. data/spec/cucumber/formatter/spec_helper.rb +8 -7
  183. data/spec/cucumber/hooks_spec.rb +1 -0
  184. data/spec/cucumber/multiline_argument/data_table_spec.rb +1 -0
  185. data/spec/cucumber/project_initializer_spec.rb +2 -1
  186. data/spec/cucumber/rake/forked_spec.rb +1 -0
  187. data/spec/cucumber/rake/task_spec.rb +1 -0
  188. data/spec/cucumber/rb_support/rb_language_spec.rb +81 -3
  189. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -0
  190. data/spec/cucumber/rb_support/rb_transform_spec.rb +1 -0
  191. data/spec/cucumber/rb_support/rb_world_spec.rb +2 -1
  192. data/spec/cucumber/rb_support/snippet_spec.rb +1 -0
  193. data/spec/cucumber/running_test_case_spec.rb +1 -0
  194. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -0
  195. data/spec/cucumber/runtime/support_code_spec.rb +1 -0
  196. data/spec/cucumber/runtime_spec.rb +1 -0
  197. data/spec/cucumber/step_argument_spec.rb +1 -0
  198. data/spec/cucumber/step_match_search_spec.rb +1 -0
  199. data/spec/cucumber/step_match_spec.rb +1 -0
  200. data/spec/cucumber/world/pending_spec.rb +1 -0
  201. data/spec/spec_helper.rb +1 -0
  202. data/spec/support/standard_step_actions.rb +1 -0
  203. metadata +24 -23
  204. data/lib/cucumber/ast.rb +0 -13
  205. data/lib/cucumber/events/after_test_case.rb +0 -25
  206. data/lib/cucumber/events/after_test_step.rb +0 -30
  207. data/lib/cucumber/events/before_test_case.rb +0 -18
  208. data/lib/cucumber/events/before_test_step.rb +0 -23
  209. data/lib/cucumber/events/bus.rb +0 -86
  210. data/lib/cucumber/events/finished_testing.rb +0 -9
  211. data/lib/cucumber/formatter/event_bus_report.rb +0 -38
  212. data/spec/cucumber/events/bus_spec.rb +0 -94
  213. data/spec/cucumber/formatter/event_bus_report_spec.rb +0 -88
  214. data/spec/cucumber_spec.rb +0 -39
@@ -0,0 +1,57 @@
1
+ require 'cucumber/formatter/console'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ class ConsoleCounts
6
+ include Console
7
+
8
+ def initialize(config)
9
+ @test_case_summary = Core::Test::Result::Summary.new
10
+ @test_step_summary = Core::Test::Result::Summary.new
11
+
12
+ config.on_event :test_case_finished do |event|
13
+ event.result.describe_to @test_case_summary
14
+ end
15
+
16
+ config.on_event :test_step_finished do |event|
17
+ event.result.describe_to @test_step_summary if from_gherkin?(event.test_step)
18
+ end
19
+ end
20
+
21
+ def to_s
22
+ [
23
+ [scenario_count, status_counts(@test_case_summary)].compact.join(" "),
24
+ [step_count, status_counts(@test_step_summary)].compact.join(" ")
25
+ ].join("\n")
26
+ end
27
+
28
+ private
29
+
30
+ def from_gherkin?(test_step)
31
+ test_step.source.last.location.file.match(/\.feature$/)
32
+ end
33
+
34
+ def scenario_count
35
+ count = @test_case_summary.total
36
+ "#{count} scenario" + (count == 1 ? "" : "s")
37
+ end
38
+
39
+ def step_count
40
+ count = @test_step_summary.total
41
+ "#{count} step" + (count == 1 ? "" : "s")
42
+ end
43
+
44
+ def status_counts(summary)
45
+ counts = [:failed, :skipped, :undefined, :pending, :passed].map { |status|
46
+ count = summary.total(status)
47
+ [status, count]
48
+ }.select { |status, count|
49
+ count > 0
50
+ }.map { |status, count|
51
+ format_string("#{count} #{status}", status)
52
+ }
53
+ "(#{counts.join(", ")})" if counts.any?
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,37 @@
1
+ require 'cucumber/formatter/console'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ class ConsoleIssues
6
+ include Console
7
+
8
+ def initialize(config)
9
+ @failures = []
10
+ @config = config
11
+ @config.on_event(:test_case_finished) do |event|
12
+ @failures << event.test_case if event.result.failed?
13
+ end
14
+ end
15
+
16
+ def to_s
17
+ return if @failures.empty?
18
+ result = [ format_string("Failing Scenarios:", :failed) ] + @failures.map { |failure|
19
+ source = @config.source? ? format_string(" # #{failure.keyword}: #{failure.name}", :comment) : ''
20
+ format_string("cucumber #{profiles_string}" + failure.location, :failed) + source
21
+ }
22
+ result.join("\n")
23
+ end
24
+
25
+ def any?
26
+ @failures.any?
27
+ end
28
+
29
+ private
30
+
31
+ def profiles_string
32
+ return if @config.custom_profiles.empty?
33
+ @config.custom_profiles.map { |profile| "-p #{profile}" }.join(' ') + ' '
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/progress'
2
3
  require 'cucumber/step_definition_light'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  module Duration
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/io'
2
3
  require 'cucumber/formatter/console'
3
4
 
@@ -7,8 +8,9 @@ module Cucumber
7
8
  class FailFast
8
9
 
9
10
  def initialize(configuration)
10
- configuration.on_event :after_test_case do |event|
11
- Cucumber.wants_to_quit = true unless event.result.ok?(configuration.strict?)
11
+ configuration.on_event :test_case_finished do |event|
12
+ test_case, result = *event.attributes
13
+ Cucumber.wants_to_quit = true unless result.ok?(configuration.strict?)
12
14
  end
13
15
  end
14
16
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  class HookQueryVisitor
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'erb'
2
3
  require 'builder'
3
4
  require 'cucumber/formatter/duration'
@@ -589,13 +590,13 @@ module Cucumber
589
590
  (["#{exception.message}"] + exception.backtrace).join("\n")
590
591
  end
591
592
 
592
- def backtrace_line(line)
593
- line.gsub(/^([^:]*\.(?:rb|feature|haml)):(\d*).*$/) do
594
- if ENV['TM_PROJECT_DIRECTORY']
593
+ def backtrace_line(line)
594
+ if ENV['TM_PROJECT_DIRECTORY']
595
+ line.gsub(/^([^:]*\.(?:rb|feature|haml)):(\d*).*$/) do
595
596
  "<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
596
- else
597
- line
598
597
  end
598
+ else
599
+ line
599
600
  end
600
601
  end
601
602
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'thread'
2
3
 
3
4
  module Cucumber
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  module Io
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'multi_json'
2
3
  require 'base64'
3
4
  require 'cucumber/formatter/backtrace_filter'
@@ -11,16 +12,16 @@ module Cucumber
11
12
  include Io
12
13
 
13
14
  def initialize(config)
14
- config.on_event :before_test_case, &method(:on_before_test_case)
15
- config.on_event :after_test_case, &method(:on_after_test_case)
16
- config.on_event :before_test_step, &method(:on_before_test_step)
17
- config.on_event :after_test_step, &method(:on_after_test_step)
18
- config.on_event :finished_testing, &method(:on_finished_testing)
19
15
  @io = ensure_io(config.out_stream)
20
16
  @feature_hashes = []
17
+ config.on_event :test_case_starting, &method(:on_test_case_starting)
18
+ config.on_event :test_case_finished, &method(:on_test_case_finished)
19
+ config.on_event :test_step_starting, &method(:on_test_step_starting)
20
+ config.on_event :test_step_finished, &method(:on_test_step_finished)
21
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
21
22
  end
22
23
 
23
- def on_before_test_case(event)
24
+ def on_test_case_starting(event)
24
25
  test_case = event.test_case
25
26
  builder = Builder.new(test_case)
26
27
  unless same_feature_as_previous_test_case?(test_case.feature)
@@ -38,7 +39,7 @@ module Cucumber
38
39
  @any_step_failed = false
39
40
  end
40
41
 
41
- def on_before_test_step(event)
42
+ def on_test_step_starting(event)
42
43
  test_step = event.test_step
43
44
  return if internal_hook?(test_step)
44
45
  hook_query = HookQueryVisitor.new(test_step)
@@ -56,20 +57,21 @@ module Cucumber
56
57
  @step_hash = @step_or_hook_hash
57
58
  end
58
59
 
59
- def on_after_test_step(event)
60
- test_step = event.test_step
61
- result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
60
+ def on_test_step_finished(event)
61
+ test_step, result = *event.attributes
62
+ result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
62
63
  return if internal_hook?(test_step)
63
64
  add_match_and_result(test_step, result)
64
65
  @any_step_failed = true if result.failed?
65
66
  end
66
67
 
67
- def on_after_test_case(event)
68
- result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
68
+ def on_test_case_finished(event)
69
+ test_case, result = *event.attributes
70
+ result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
69
71
  add_failed_around_hook(result) if result.failed? && !@any_step_failed
70
72
  end
71
73
 
72
- def on_finished_testing(event)
74
+ def on_test_run_finished(event)
73
75
  @io.write(MultiJson.dump(@feature_hashes, pretty: true))
74
76
  end
75
77
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/json'
2
3
 
3
4
  module Cucumber
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'builder'
2
3
  require 'cucumber/formatter/backtrace_filter'
3
4
  require 'cucumber/formatter/io'
@@ -18,10 +19,10 @@ module Cucumber
18
19
  end
19
20
 
20
21
  def initialize(config)
21
- config.on_event :before_test_case, &method(:on_before_test_case)
22
- config.on_event :after_test_case, &method(:on_after_test_case)
23
- config.on_event :after_test_step, &method(:on_after_test_step)
24
- config.on_event :finished_testing, &method(:on_finished_testing)
22
+ config.on_event :test_case_starting, &method(:on_test_case_starting)
23
+ config.on_event :test_case_finished, &method(:on_test_case_finished)
24
+ config.on_event :test_step_finished, &method(:on_test_step_finished)
25
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
25
26
  @reportdir = ensure_dir(config.out_stream, "junit")
26
27
  @config = config
27
28
  @features_data = Hash.new { |h,k| h[k] = {
@@ -35,7 +36,7 @@ module Cucumber
35
36
  }}
36
37
  end
37
38
 
38
- def on_before_test_case(event)
39
+ def on_test_case_starting(event)
39
40
  test_case = event.test_case
40
41
  unless same_feature_as_previous_test_case?(test_case.feature)
41
42
  start_feature(test_case.feature)
@@ -47,15 +48,16 @@ module Cucumber
47
48
  @interceptederr = Interceptor::Pipe.wrap(:stderr)
48
49
  end
49
50
 
50
- def on_after_test_step(event)
51
+ def on_test_step_finished(event)
52
+ test_step, result = *event.attributes
51
53
  return if @failing_step_source
52
54
 
53
- @failing_step_source = event.test_step.source.last unless event.result.ok?(@config.strict?)
55
+ @failing_step_source = test_step.source.last unless result.ok?(@config.strict?)
54
56
  end
55
57
 
56
- def on_after_test_case(event)
57
- test_case = event.test_case
58
- result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
58
+ def on_test_case_finished(event)
59
+ test_case, result = *event.attributes
60
+ result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
59
61
  test_case_name = NameBuilder.new(test_case)
60
62
  scenario = test_case_name.scenario_name
61
63
  scenario_designation = "#{scenario}#{test_case_name.name_suffix}"
@@ -66,7 +68,7 @@ module Cucumber
66
68
  Interceptor::Pipe.unwrap! :stderr
67
69
  end
68
70
 
69
- def on_finished_testing(event)
71
+ def on_test_run_finished(event)
70
72
  @features_data.each { |file, data| end_feature(data) }
71
73
  end
72
74
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'forwardable'
2
3
  require 'delegate'
3
4
  require 'cucumber/errors'
@@ -15,44 +16,38 @@ module Cucumber
15
16
  def initialize(*)
16
17
  super
17
18
  @matches = collect_matches
19
+ config.on_event(:test_case_starting) do |event|
20
+ formatter.before_test_case(event.test_case)
21
+ printer.before_test_case(event.test_case)
22
+ end
23
+ config.on_event(:test_step_starting) do |event|
24
+ formatter.before_test_step(event.test_step)
25
+ printer.before_test_step(event.test_step)
26
+ end
27
+ config.on_event(:test_step_finished) do |event|
28
+ test_step, result = *event.attributes
29
+ printer.after_test_step(test_step, result)
30
+ formatter.after_test_step(test_step, result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter))
31
+ end
32
+ config.on_event(:test_case_finished) do |event|
33
+ test_case, result = *event.attributes
34
+ record_test_case_result(test_case, result)
35
+ printer.after_test_case(test_case, result)
36
+ formatter.after_test_case(test_case, result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter))
37
+ end
38
+ config.on_event(:test_run_finished) do
39
+ printer.after
40
+ formatter.done
41
+ end
18
42
  end
19
43
 
20
- def_delegators :formatter,
21
- :ask
22
-
23
- def_delegators :printer,
24
- :embed
25
-
26
- def before_test_case(test_case)
27
- formatter.before_test_case(test_case)
28
- printer.before_test_case(test_case)
29
- end
30
-
31
- def before_test_step(test_step)
32
- formatter.before_test_step(test_step)
33
- printer.before_test_step(test_step)
34
- end
35
-
36
- def after_test_step(test_step, result)
37
- printer.after_test_step(test_step, result)
38
- formatter.after_test_step(test_step, result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter))
39
- end
40
-
41
- def after_test_case(test_case, result)
42
- record_test_case_result(test_case, result)
43
- printer.after_test_case(test_case, result)
44
- formatter.after_test_case(test_case, result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter))
45
- end
44
+ def_delegators :formatter, :ask
45
+ def_delegators :printer, :embed
46
46
 
47
47
  def puts(*messages)
48
48
  printer.puts(messages)
49
49
  end
50
50
 
51
- def done
52
- printer.after
53
- formatter.done
54
- end
55
-
56
51
  private
57
52
 
58
53
  def printer
@@ -67,7 +62,8 @@ module Cucumber
67
62
  def collect_matches
68
63
  result = {}
69
64
  config.on_event(:step_match) do |event|
70
- result[event.test_step.source.last] = event.step_match
65
+ test_step, step_match = *event.attributes
66
+ result[test_step.source.last] = step_match
71
67
  end
72
68
  result
73
69
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  module LegacyApi
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  module LegacyApi
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/gherkin/i18n'
2
3
 
3
4
  module Cucumber
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'fileutils'
2
3
  require 'cucumber/formatter/console'
3
4
  require 'cucumber/formatter/io'
4
5
  require 'cucumber/gherkin/formatter/escaping'
6
+ require 'cucumber/formatter/console_counts'
7
+ require 'cucumber/formatter/console_issues'
5
8
 
6
9
  module Cucumber
7
10
  module Formatter
@@ -22,12 +25,15 @@ module Cucumber
22
25
 
23
26
  def initialize(runtime, path_or_io, options)
24
27
  @runtime, @io, @options = runtime, ensure_io(path_or_io), options
28
+ @config = runtime.configuration
25
29
  @exceptions = []
26
30
  @indent = 0
27
31
  @prefixes = options[:prefixes] || {}
28
32
  @delayed_messages = []
29
33
  @previous_step_keyword = nil
30
34
  @snippets_input = []
35
+ @counts = ConsoleCounts.new(runtime.configuration)
36
+ @issues = ConsoleIssues.new(runtime.configuration)
31
37
  end
32
38
 
33
39
  def before_features(features)
@@ -238,7 +244,7 @@ module Cucumber
238
244
  end
239
245
 
240
246
  def print_summary(features)
241
- print_stats(features, @options)
247
+ print_statistics(features.duration, @config, @counts, @issues)
242
248
  print_snippets(@options)
243
249
  print_passing_wip(@options)
244
250
  end