Class: Moto::Reporting::TestReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/reporting/test_reporter.rb

Overview

Manages reporting test and run status’ to attached listeners

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(listeners, run_params) ⇒ TestReporter

@param run_params Variables specified by the user when parametrizing current moto run

suite_name: String Name of the test suite
run_name:   String Name of the test run, may be custom made or automatically generated
assignee:   ID of person responsible for test run

Parameters:

  • listeners (Array)

    An array of strings, which represent qualified names of classes (listeners) that will be instantiated. empty array is passed then :default_listeners will be taken from config



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/reporting/test_reporter.rb', line 18

def initialize(listeners, run_params)

  if listeners.empty?
    config[:default_listeners].each do |listener_class_name|
      listeners << listener_class_name
    end
  else
    listeners.each_with_index do |listener_class_name, index|
      listeners[index] = ('Moto::Reporting::Listeners::' + listener_class_name.camelize).constantize
    end
  end

  @listeners = []
  @run_params = run_params
  listeners.each { |l| add_listener(l) }
end

Instance Attribute Details

#run_statusObject (readonly)

Returns the value of attribute run_status.



10
11
12
# File 'lib/reporting/test_reporter.rb', line 10

def run_status
  @run_status
end

Instance Method Details

#add_listener(listener) ⇒ Object

Adds a listener to the list. All listeners on the list will have events reported to them.

Parameters:

  • listener (Moto::Listener::Base)

    class to be added



38
39
40
# File 'lib/reporting/test_reporter.rb', line 38

def add_listener(listener)
  @listeners << listener.new(@run_params)
end

#report_end_runObject

Reports end of the whole run (set of tests) to attached listeners



53
54
55
56
57
58
59
# File 'lib/reporting/test_reporter.rb', line 53

def report_end_run
  @run_status.finalize_run

  @listeners.each do |l|
    l.end_run(@run_status)
  end
end

#report_end_test(test_status) ⇒ Object

Reports end of a test to all attached listeners

Parameters:



72
73
74
75
76
77
78
# File 'lib/reporting/test_reporter.rb', line 72

def report_end_test(test_status)
  @run_status.add_test_status(test_status)

  @listeners.each do |l|
    l.end_test(test_status)
  end
end

#report_start_runObject

Reports start of the whole run (set of tests) to attached listeners



43
44
45
46
47
48
49
50
# File 'lib/reporting/test_reporter.rb', line 43

def report_start_run
  @run_status = Moto::Reporting::RunStatus.new
  @run_status.initialize_run

  @listeners.each do |l|
    l.start_run
  end
end

#report_start_test(test_status, test_metadata) ⇒ Object

Reports star of a test to all attached listeners

Parameters:



64
65
66
67
68
# File 'lib/reporting/test_reporter.rb', line 64

def report_start_test(test_status, )
  @listeners.each do |l|
    l.start_test(test_status, )
  end
end