class ReportPortal::Cucumber::ParallelFormatter

Public Class Methods

new(config) click to toggle source

@api private

# File lib/report_portal/cucumber/parallel_formatter.rb, line 29
def initialize(config)
  ENV['REPORT_PORTAL_USED'] = 'true'

  @queue = Queue.new
  @thread = Thread.new do
    @report = ReportPortal::Cucumber::ParallelReport.new
    loop do
      method_arr = @queue.pop
      @report.public_send(*method_arr)
    end
  end
  @thread.abort_on_exception = true

  @io = config.out_stream

  [:test_case_started, :test_case_finished, :test_step_started, :test_step_finished].each do |event_name|
    config.on_event event_name do |event|
      @queue.push([event_name, event, ReportPortal.now])
    end
  end
  config.on_event :test_run_finished, &method(:on_test_run_finished)
end