Sha256: b7dd900e3456aea2302d0af22515daff257af43502d26a79791816e289544222

Contents?: true

Size: 1.75 KB

Versions: 16

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

require 'cucumber/formatter/io'
require 'cucumber/formatter/console'
require 'cucumber/formatter/console_counts'
require 'cucumber/formatter/console_issues'
require 'cucumber/core/test/result'
require 'cucumber/formatter/ast_lookup'

module Cucumber
  module Formatter
    # Summary formatter, outputting only feature / scenario titles
    class Summary
      include Io
      include Console

      def initialize(config)
        @config = config
        @io = ensure_io(config.out_stream, config.error_stream)
        @ast_lookup = AstLookup.new(config)
        @counts = ConsoleCounts.new(@config)
        @issues = ConsoleIssues.new(@config, @ast_lookup)
        @start_time = Time.now

        @config.on_event :test_case_started do |event|
          print_feature event.test_case
          print_test_case event.test_case
        end

        @config.on_event :test_case_finished do |event|
          print_result event.result
        end

        @config.on_event :test_run_finished do |_event|
          duration = Time.now - @start_time
          @io.puts
          print_statistics(duration, @config, @counts, @issues)
        end
      end

      private

      def gherkin_document(uri)
        @ast_lookup.gherkin_document(uri)
      end

      def print_feature(test_case)
        uri = test_case.location.file
        return if @current_feature_uri == uri

        feature_name = gherkin_document(uri).feature.name
        @io.puts unless @current_feature_uri.nil?
        @io.puts feature_name
        @current_feature_uri = uri
      end

      def print_test_case(test_case)
        @io.print "  #{test_case.name} "
      end

      def print_result(result)
        @io.puts format_string(result, result.to_sym)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
cucumber-9.2.1 lib/cucumber/formatter/summary.rb
cucumber-9.2.0 lib/cucumber/formatter/summary.rb
cucumber-9.1.2 lib/cucumber/formatter/summary.rb
cucumber-9.1.1 lib/cucumber/formatter/summary.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/formatter/summary.rb
cucumber-9.1.0 lib/cucumber/formatter/summary.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/formatter/summary.rb
cucumber-9.0.2 lib/cucumber/formatter/summary.rb
cucumber-9.0.1 lib/cucumber/formatter/summary.rb
cucumber-9.0.0 lib/cucumber/formatter/summary.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/summary.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/summary.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/summary.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/summary.rb
cucumber-8.0.0 lib/cucumber/formatter/summary.rb
cucumber-8.0.0.rc.1 lib/cucumber/formatter/summary.rb