Class: CI::Reporter::TestCase
- Inherits:
-
Struct
- Object
- Struct
- CI::Reporter::TestCase
- Defined in:
- lib/ci/reporter/test_suite.rb
Overview
Structure used to represent an individual test case. Used to time the test and store the result.
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Returns the value of attribute assertions.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#name ⇒ Object
Returns the value of attribute name.
-
#skipped ⇒ Object
Returns the value of attribute skipped.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Returns non-nil if the test had an error.
-
#failure? ⇒ Boolean
Returns non-nil if the test failed.
-
#finish ⇒ Object
Finishes timing the test.
-
#initialize(*args) ⇒ TestCase
constructor
A new instance of TestCase.
- #skipped? ⇒ Boolean
-
#start ⇒ Object
Starts timing the test.
-
#to_xml(builder) ⇒ Object
Writes xml representing the test result to the provided builder.
Constructor Details
#initialize(*args) ⇒ TestCase
Returns a new instance of TestCase.
118 119 120 121 |
# File 'lib/ci/reporter/test_suite.rb', line 118 def initialize(*args) super @failures = [] end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions
114 115 116 |
# File 'lib/ci/reporter/test_suite.rb', line 114 def assertions @assertions end |
#failures ⇒ Object
Returns the value of attribute failures.
115 116 117 |
# File 'lib/ci/reporter/test_suite.rb', line 115 def failures @failures end |
#name ⇒ Object
Returns the value of attribute name
114 115 116 |
# File 'lib/ci/reporter/test_suite.rb', line 114 def name @name end |
#skipped ⇒ Object
Returns the value of attribute skipped.
116 117 118 |
# File 'lib/ci/reporter/test_suite.rb', line 116 def skipped @skipped end |
#time ⇒ Object
Returns the value of attribute time
114 115 116 |
# File 'lib/ci/reporter/test_suite.rb', line 114 def time @time end |
Instance Method Details
#error? ⇒ Boolean
Returns non-nil if the test had an error.
139 140 141 |
# File 'lib/ci/reporter/test_suite.rb', line 139 def error? !failures.empty? && failures.detect {|f| f.error? } end |
#failure? ⇒ Boolean
Returns non-nil if the test failed.
134 135 136 |
# File 'lib/ci/reporter/test_suite.rb', line 134 def failure? !failures.empty? && failures.detect {|f| f.failure? } end |
#finish ⇒ Object
Finishes timing the test.
129 130 131 |
# File 'lib/ci/reporter/test_suite.rb', line 129 def finish self.time = Time.now - @start end |
#skipped? ⇒ Boolean
143 144 145 |
# File 'lib/ci/reporter/test_suite.rb', line 143 def skipped? return skipped end |
#start ⇒ Object
Starts timing the test.
124 125 126 |
# File 'lib/ci/reporter/test_suite.rb', line 124 def start @start = Time.now end |
#to_xml(builder) ⇒ Object
Writes xml representing the test result to the provided builder.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# 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.)) do builder.text!(failure. + " (#{failure.name})\n") builder.text!(failure.location) end end end end end |