Sha256: 8f27f7da1108808d0d8a13995ae62387e469acd49b065775dc8f7d3416ecd9e7

Contents?: true

Size: 1.04 KB

Versions: 29

Compression:

Stored size: 1.04 KB

Contents

require 'cucumber/formatter/console'

module Cucumber
  module Formatter
    class ConsoleCounts
      include Console

      def initialize(config)
        @summary = Core::Report::Summary.new(config.event_bus)
      end

      def to_s
        [
          [scenario_count, status_counts(@summary.test_cases)].compact.join(' '),
          [step_count, status_counts(@summary.test_steps)].compact.join(' ')
        ].join("\n")
      end

      private

      def scenario_count
        count = @summary.test_cases.total
        "#{count} scenario" + (count == 1 ? '' : 's')
      end

      def step_count
        count = @summary.test_steps.total
        "#{count} step" + (count == 1 ? '' : 's')
      end

      def status_counts(summary)
        counts = Core::Test::Result::TYPES.map { |status| [status, summary.total(status)] }
        counts = counts.select { |_status, count| count > 0 }
        counts = counts.map { |status, count| format_string("#{count} #{status}", status) }
        "(#{counts.join(', ')})" if counts.any?
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
cucumber-9.0.1 lib/cucumber/formatter/console_counts.rb
cucumber-9.0.0 lib/cucumber/formatter/console_counts.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/console_counts.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/console_counts.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/console_counts.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/console_counts.rb
cucumber-8.0.0 lib/cucumber/formatter/console_counts.rb
cucumber-8.0.0.rc.1 lib/cucumber/formatter/console_counts.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/formatter/console_counts.rb
cucumber-7.1.0 lib/cucumber/formatter/console_counts.rb
cucumber-7.0.0 lib/cucumber/formatter/console_counts.rb
cucumber-6.1.0 lib/cucumber/formatter/console_counts.rb
cucumber-6.0.0 lib/cucumber/formatter/console_counts.rb
cucumber-5.3.0 lib/cucumber/formatter/console_counts.rb
cucumber-5.2.0 lib/cucumber/formatter/console_counts.rb
cucumber-5.1.3 lib/cucumber/formatter/console_counts.rb
cucumber-5.1.2 lib/cucumber/formatter/console_counts.rb
cucumber-5.1.1 lib/cucumber/formatter/console_counts.rb
cucumber-5.1.0 lib/cucumber/formatter/console_counts.rb
cucumber-5.0.0 lib/cucumber/formatter/console_counts.rb