Class CI::Reporter::TestCase
In: lib/ci/reporter/test_suite.rb
Parent: Struct.new(:name, :time, :assertions)

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

Methods

error?   failure?   finish   new   skipped?   start   to_xml  

Attributes

failures  [RW] 
skipped  [RW] 

Public Class methods

[Source]

     # File lib/ci/reporter/test_suite.rb, line 104
104:       def  initializeinitialize(*args)
105:         super
106:         @failures = []
107:       end

Public Instance methods

Returns non-nil if the test had an error.

[Source]

     # File lib/ci/reporter/test_suite.rb, line 125
125:       def error?
126:         !failures.empty? && failures.detect {|f| f.error? }
127:       end

Returns non-nil if the test failed.

[Source]

     # File lib/ci/reporter/test_suite.rb, line 120
120:       def failure?
121:         !failures.empty? && failures.detect {|f| f.failure? }
122:       end

Finishes timing the test.

[Source]

     # File lib/ci/reporter/test_suite.rb, line 115
115:       def finish
116:         self.time = Time.now - @start
117:       end

[Source]

     # File lib/ci/reporter/test_suite.rb, line 129
129:       def skipped?
130:         return skipped
131:       end

Starts timing the test.

[Source]

     # File lib/ci/reporter/test_suite.rb, line 110
110:       def start
111:         @start = Time.now
112:       end

Writes xml representing the test result to the provided builder.

[Source]

     # File lib/ci/reporter/test_suite.rb, line 134
134:       def to_xml(builder)
135:         attrs = {}
136:         each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty?}
137:         builder.testcase(attrs) do
138:           if skipped
139:             builder.skipped
140:           else
141:             failures.each do |failure|
142:               builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
143:                 builder.text!(failure.message + " (#{failure.name})\n")
144:                 builder.text!(failure.location)
145:               end
146:             end
147:           end
148:         end
149:       end

[Validate]