Class: ParallelTests::Cucumber::FailuresLogger

Inherits:
Cucumber::Formatter::Rerun
  • Object
show all
Includes:
Gherkin::Io
Defined in:
lib/parallel_tests/cucumber/failures_logger.rb

Instance Method Summary collapse

Methods included from Gherkin::Io

#lock_output, #prepare_io

Constructor Details

#initialize(config) ⇒ FailuresLogger

Returns a new instance of FailuresLogger.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/parallel_tests/cucumber/failures_logger.rb', line 11

def initialize(config)
  super

  @io = prepare_io(config.out_stream)

  # Remove handler inherited from Cucumber::Formatter::Rerun that does not
  # properly join file failures
  handlers = config.event_bus.instance_variable_get(:@handlers)
  handlers[::Cucumber::Events::TestRunFinished.to_s].pop

  # Add our own handler
  config.on_event :test_run_finished do
    next if @failures.empty?

    lock_output do
      @failures.each do |file, lines|
        lines.each do |line|
          @io.print "#{file}:#{line} "
        end
      end
    end
  end
end