You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

summary.rb 1.8 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. require 'cucumber/formatter/ast_lookup'
  8. module Cucumber
  9. module Formatter
  10. # Summary formatter, outputting only feature / scenario titles
  11. class Summary
  12. include Io
  13. include Console
  14. def initialize(config)
  15. @config = config
  16. @io = ensure_io(config.out_stream, config.error_stream)
  17. @ast_lookup = AstLookup.new(config)
  18. @counts = ConsoleCounts.new(@config)
  19. @issues = ConsoleIssues.new(@config, @ast_lookup)
  20. @start_time = Time.now
  21. @config.on_event :test_case_started do |event|
  22. print_feature event.test_case
  23. print_test_case event.test_case
  24. end
  25. @config.on_event :test_case_finished do |event|
  26. print_result event.result
  27. end
  28. @config.on_event :test_run_finished do |_event|
  29. duration = Time.now - @start_time
  30. @io.puts
  31. print_statistics(duration, @config, @counts, @issues)
  32. end
  33. end
  34. private
  35. def gherkin_document(uri)
  36. @ast_lookup.gherkin_document(uri)
  37. end
  38. def print_feature(test_case)
  39. uri = test_case.location.file
  40. return if @current_feature_uri == uri
  41. feature_name = gherkin_document(uri).feature.name
  42. @io.puts unless @current_feature_uri.nil?
  43. @io.puts feature_name
  44. @current_feature_uri = uri
  45. end
  46. def print_test_case(test_case)
  47. @io.print " #{test_case.name} "
  48. end
  49. def print_result(result)
  50. @io.puts format_string(result, result.to_sym)
  51. end
  52. end
  53. end
  54. end

No Description

Contributors (1)