Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
GH ci-reporter#3: Support for Omissions and Pending Tests from Test::…
Browse files Browse the repository at this point in the history
…Unit 2.0.x (Sam Hendley)
  • Loading branch information
nicksieger committed Mar 26, 2010
1 parent a5d3b65 commit 4ac3561
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/ci/reporter/test_unit.rb
Expand Up @@ -12,15 +12,15 @@ module Reporter
# of the test.
class Failure
def self.new(fault)
fault.kind_of?(Test::Unit::Failure) ? TestUnitFailure.new(fault) : TestUnitError.new(fault)
return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
return TestUnitSkipped.new(fault) if Test::Unit.constants.include?("Omission") && (fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
TestUnitError.new(fault)
end
end

# Wrapper around a <code>Test::Unit</code> error to be used by the test suite to interpret results.
class TestUnitError
def initialize(fault)
@fault = fault
end
def initialize(fault) @fault = fault end
def failure?() false end
def error?() true end
def name() @fault.exception.class.name end
Expand All @@ -30,16 +30,24 @@ def location() @fault.exception.backtrace.join("\n") end

# Wrapper around a <code>Test::Unit</code> failure to be used by the test suite to interpret results.
class TestUnitFailure
def initialize(fault)
@fault = fault
end
def initialize(fault) @fault = fault end
def failure?() true end
def error?() false end
def name() Test::Unit::AssertionFailedError.name end
def message() @fault.message end
def location() @fault.location.join("\n") end
end

# Wrapper around a <code>Test::Unit</code> 2.0 omission.
class TestUnitSkipped
def initialize(fault) @fault = fault end
def failure?() false end
def error?() false end
def name() Test::Unit::Omission.name end
def message() @fault.message end
def location() @fault.location.join("\n") end
end

# Replacement Mediator that adds listeners to capture the results of the <code>Test::Unit</code> runs.
class TestUnit < Test::Unit::UI::TestRunnerMediator
def initialize(suite, report_mgr = nil)
Expand Down Expand Up @@ -100,7 +108,7 @@ def start_suite(suite_name)

def finish_suite
if @current_suite
@current_suite.finish
@current_suite.finish
@current_suite.assertions = @suite_result.assertion_count - @last_assertion_count
@last_assertion_count = @suite_result.assertion_count
@report_manager.write_report(@current_suite)
Expand Down

0 comments on commit 4ac3561

Please sign in to comment.