Class: CI::Reporter::TestUnit

Inherits:
Test::Unit::UI::TestRunnerMediator
  • Object
show all
Defined in:
lib/ci/reporter/test_unit.rb

Overview

Replacement Mediator that adds listeners to capture the results of the Test::Unit runs.

Instance Method Summary collapse

Constructor Details

#initialize(suite, report_mgr = nil) ⇒ TestUnit

Returns a new instance of TestUnit.



64
65
66
67
68
69
70
71
72
# File 'lib/ci/reporter/test_unit.rb', line 64

def initialize(suite, report_mgr = nil)
  super(suite)
  @report_manager = report_mgr || ReportManager.new("test")
  add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
  add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
  add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
  add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
  add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED, &method(:finished))
end

Instance Method Details

#fault(fault) ⇒ Object



95
96
97
98
# File 'lib/ci/reporter/test_unit.rb', line 95

def fault(fault)
  tc = @current_suite.testcases.last
  tc.failures << Failure.new(fault)
end

#finished(elapsed_time) ⇒ Object



100
101
102
# File 'lib/ci/reporter/test_unit.rb', line 100

def finished(elapsed_time)
  finish_suite
end

#started(result) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/ci/reporter/test_unit.rb', line 74

def started(result)
  @suite_result = result
  @last_assertion_count = 0
  @current_suite = nil
  @unknown_count = 0
  @result_assertion_count = 0
end

#test_finished(name) ⇒ Object



91
92
93
# File 'lib/ci/reporter/test_unit.rb', line 91

def test_finished(name)
  finish_test
end

#test_started(name) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/ci/reporter/test_unit.rb', line 82

def test_started(name)
  test_name, suite_name = extract_names(name)
  unless @current_suite && @current_suite.name == suite_name
    finish_suite
    start_suite(suite_name)
  end
  start_test(test_name)
end