Parent

CI::Reporter::TestCase

Structure used to represent an individual test case. Used to time the test and store the result.

Attributes

failures[RW]
skipped[RW]

Public Class Methods

new(*args) click to toggle source
# File lib/ci/reporter/test_suite.rb, line 118
def initialize(*args)
  super
  @failures = []
end

Public Instance Methods

error?() click to toggle source

Returns non-nil if the test had an error.

# File lib/ci/reporter/test_suite.rb, line 139
def error?
  !failures.empty? && failures.detect {|f| f.error? }
end
failure?() click to toggle source

Returns non-nil if the test failed.

# File lib/ci/reporter/test_suite.rb, line 134
def failure?
  !failures.empty? && failures.detect {|f| f.failure? }
end
finish() click to toggle source

Finishes timing the test.

# File lib/ci/reporter/test_suite.rb, line 129
def finish
  self.time = Time.now - @start
end
skipped?() click to toggle source
# File lib/ci/reporter/test_suite.rb, line 143
def skipped?
  return skipped
end
start() click to toggle source

Starts timing the test.

# File lib/ci/reporter/test_suite.rb, line 124
def start
  @start = Time.now
end
to_xml(builder) click to toggle source

Writes xml representing the test result to the provided builder.

# File lib/ci/reporter/test_suite.rb, line 148
def to_xml(builder)
  attrs = {}
  each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty?}
  builder.testcase(attrs) do
    if skipped
      builder.skipped
    else
      failures.each do |failure|
        tag = case failure.class.name
              when /TestUnitSkipped/ then :skipped
              when /TestUnitError/, /MiniTestError/ then :error
              else :failure end

        builder.tag!(tag, :type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
          builder.text!(failure.message + " (#{failure.name})\n")
          builder.text!(failure.location)
        end
      end
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.