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.



53
54
55
56
57
58
59
60
61
# File 'lib/ci/reporter/test_unit.rb', line 53

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



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

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

#finished(elapsed_time) ⇒ Object



89
90
91
# File 'lib/ci/reporter/test_unit.rb', line 89

def finished(elapsed_time)
  finish_suite
end

#started(result) ⇒ Object



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

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



80
81
82
# File 'lib/ci/reporter/test_unit.rb', line 80

def test_finished(name)
  finish_test
end

#test_started(name) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/ci/reporter/test_unit.rb', line 71

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