CI_reporter throws undefined method Test::Unit::Omission #51

Closed
PiotrNestor opened this Issue Feb 9, 2012 · 2 comments

2 participants

@PiotrNestor

Environment: Ruby 1.9.3-p0, test-unit 2.4.5

When 'omit' is used the CI_reporter fails:
./usr/local/rvm/gems/ruby-1.9.3-p0/gems/ci_reporter-1.7.0/lib/ci/reporter/test_unit.rb:29:in name': undefined methodexception' for #Test::Unit::Omission:0x8f8660c (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/ci_reporter-1.7.0/lib/ci/reporter/test_suite.rb:146:in block (2 levels) in to_xml'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/ci_reporter-1.7.0/lib/ci/reporter/test_suite.rb:140:in
each'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/ci_reporter-1.7.0/lib/ci/reporter/test_suite.rb:140:in `block in to_xml'

The test example:
require 'rubygems'
gem 'test-unit'
require 'test/unit'
require "ci/reporter/rake/test_unit_loader"

class TC_MyTests < Test::Unit::TestCase
def test_01_login
puts "Logged in"
end

def test_02_omit
puts "Hello 1"
omit()
puts "Hello 2"
end

def test_03_logoff
puts "Logged off"
end
end

@nicksieger
ci-reporter member

Thanks for the example. Hopefully there's an easy fix to this, because the code is supposed to handle omissions already.

@PiotrNestor

I think the error is in the CI::Reporter::Failure class

The fix is to use a the symbols :Omission, :Notification when testing the contents of Test::Unit.constants array

class Failure
  def self.new(fault)
    return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
    return TestUnitSkipped.new(fault) if Test::Unit.constants.include?(:Omission) ....
    return TestUnitNotification.new(fault) if Test::Unit.constants.include?(:Notification) ....
    TestUnitError.new(fault)
  end
end
@kou kou added a commit that referenced this issue May 11, 2012
@kou kou Use const_defined? for checking a constant is defined
#51 uses !(Test::Unit.constants & [:Omission, "Omission"]).empty? for
checking a constant is defined. But it's better that Module#const_defined?
is used for that propose.
e7a0ff8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment