class ReportPortal::Cucumber::Formatter
Public Class Methods
new(config)
click to toggle source
@api private
# File lib/report_portal/cucumber/formatter.rb, line 7 def initialize(config) ENV['REPORT_PORTAL_USED'] = 'true' setup_message_processing @io = config.out_stream %i[test_case_started test_case_finished test_step_started test_step_finished test_run_finished].each do |event_name| config.on_event event_name do |event| process_message(event_name, event) end end config.on_event(:test_run_finished) { finish_message_processing } end
Public Instance Methods
embed(*args)
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 28 def embed(*args) process_message(:embed, *args) end
puts(message)
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 22 def puts(message) process_message(:puts, message) @io.puts(message) @io.flush end
Private Instance Methods
finish_message_processing()
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 51 def finish_message_processing return if use_same_thread_for_reporting? sleep 0.03 while !@queue.empty? || @queue.num_waiting.zero? # TODO: how to interrupt launch if the user aborted execution @thread.kill end
process_message(report_method_name, *method_args)
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 58 def process_message(report_method_name, *method_args) args = [report_method_name, *method_args, ReportPortal.now] if use_same_thread_for_reporting? report.public_send(*args) else @queue.push(args) end end
report()
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 34 def report @report ||= ReportPortal::Cucumber::Report.new end
setup_message_processing()
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 38 def setup_message_processing return if use_same_thread_for_reporting? @queue = Queue.new @thread = Thread.new do loop do method_arr = @queue.pop report.public_send(*method_arr) end end @thread.abort_on_exception = true end
use_same_thread_for_reporting?()
click to toggle source
# File lib/report_portal/cucumber/formatter.rb, line 67 def use_same_thread_for_reporting? ReportPortal::Settings.instance.formatter_modes.include?('use_same_thread_for_reporting') end