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.

console_counts.rb 1.1 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'cucumber/formatter/console'
  2. module Cucumber
  3. module Formatter
  4. class ConsoleCounts
  5. include Console
  6. def initialize(config)
  7. @summary = Core::Report::Summary.new(config.event_bus)
  8. end
  9. def to_s
  10. [
  11. [scenario_count, status_counts(@summary.test_cases)].compact.join(' '),
  12. [step_count, status_counts(@summary.test_steps)].compact.join(' ')
  13. ].join("\n")
  14. end
  15. private
  16. def scenario_count
  17. count = @summary.test_cases.total
  18. "#{count} scenario" + (count == 1 ? '' : 's')
  19. end
  20. def step_count
  21. count = @summary.test_steps.total
  22. "#{count} step" + (count == 1 ? '' : 's')
  23. end
  24. def status_counts(summary)
  25. counts = Core::Test::Result::TYPES.map { |status| [status, summary.total(status)] }
  26. counts = counts.select { |_status, count| count > 0 }
  27. counts = counts.map { |status, count| format_string("#{count} #{status}", status) }
  28. "(#{counts.join(', ')})" if counts.any?
  29. end
  30. end
  31. end
  32. end

No Description

Contributors (1)