class CI::Reporter::TestSuite
Basic structure representing the running of a test suite. Used to time tests and store results.
Attributes
stderr[RW]
stdout[RW]
testcases[RW]
Public Class Methods
new(name)
click to toggle source
Calls superclass method
# File lib/ci/reporter/test_suite.rb, line 32 def initialize(name) super(name.to_s) # RSpec passes a "description" object instead of a string @testcases = [] end
Public Instance Methods
finish()
click to toggle source
Finishes timing the test suite.
# File lib/ci/reporter/test_suite.rb, line 47 def finish self.tests = testcases.size self.time = Time.now - @start self.timestamp = @start.iso8601 self.failures = testcases.map(&:failure_count).reduce(&:+) self.errors = testcases.map(&:error_count).reduce(&:+) self.skipped = testcases.count(&:skipped?) self.stdout = @capture_out.finish if @capture_out self.stderr = @capture_err.finish if @capture_err end
start()
click to toggle source
Starts timing the test suite.
# File lib/ci/reporter/test_suite.rb, line 38 def start @start = Time.now unless ENV['CI_CAPTURE'] == "off" @capture_out = OutputCapture.wrap($stdout) {|io| $stdout = io } @capture_err = OutputCapture.wrap($stderr) {|io| $stderr = io } end end
to_xml()
click to toggle source
Creates an xml string containing the test suite results.
# File lib/ci/reporter/test_suite.rb, line 59 def to_xml builder = Builder::XmlMarkup.new(indent: 2) builder.instruct! builder.testsuite(cleaned_attributes) do @testcases.each do |tc| tc.to_xml(builder) end unless self.stdout.to_s.empty? builder.tag! "system-out" do builder.text!(self.stdout) end end unless self.stderr.to_s.empty? builder.tag! "system-err" do builder.text!(self.stderr) end end end end