class 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
Calls superclass method
# File lib/ci/reporter/test_suite.rb, line 91
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 112
def error?
  failures.any?(&:error?)
end
error_count() click to toggle source
# File lib/ci/reporter/test_suite.rb, line 120
def error_count
  failures.count(&:error?)
end
failure?() click to toggle source

Returns non-nil if the test failed.

# File lib/ci/reporter/test_suite.rb, line 107
def failure?
  failures.any?(&:failure?)
end
failure_count() click to toggle source
# File lib/ci/reporter/test_suite.rb, line 116
def failure_count
  failures.count(&:failure?)
end
finish() click to toggle source

Finishes timing the test.

# File lib/ci/reporter/test_suite.rb, line 102
def finish
  self.time = MonotonicTime.time_in_seconds - @start
end
skipped?() click to toggle source
# File lib/ci/reporter/test_suite.rb, line 124
def skipped?
  skipped
end
start() click to toggle source

Starts timing the test.

# File lib/ci/reporter/test_suite.rb, line 97
def start
  @start = MonotonicTime.time_in_seconds
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 129
def to_xml(builder)
  builder.testcase(cleaned_attributes) do
    if skipped?
      builder.skipped
    else
      failures.each do |failure|
        tag = failure.error? ? :error : :failure

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