Class: Moto::Reporting::TestReporter
- Inherits:
-
Object
- Object
- Moto::Reporting::TestReporter
- Defined in:
- lib/reporting/test_reporter.rb
Overview
Manages reporting test and run status’ to attached listeners
Instance Attribute Summary collapse
-
#run_status ⇒ Object
readonly
Returns the value of attribute run_status.
Instance Method Summary collapse
-
#add_listener(listener) ⇒ Object
Adds a listener to the list.
-
#initialize(listeners, run_params) ⇒ TestReporter
constructor
@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.
-
#report_end_run ⇒ Object
Reports end of the whole run (set of tests) to attached listeners.
-
#report_end_test(test_status) ⇒ Object
Reports end of a test to all attached listeners.
-
#report_start_run ⇒ Object
Reports start of the whole run (set of tests) to attached listeners.
-
#report_start_test(test_status, test_metadata) ⇒ Object
Reports star of a test to all attached listeners.
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
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_status ⇒ Object (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.
38 39 40 |
# File 'lib/reporting/test_reporter.rb', line 38 def add_listener(listener) @listeners << listener.new(@run_params) end |
#report_end_run ⇒ Object
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
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_run ⇒ Object
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
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 |