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.
-
#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.
-
#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.
111 112 113 114 |
# File 'lib/ci/reporter/test_suite.rb', line 111 def initialize(*args) super @failures = [] end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions
108 109 110 |
# File 'lib/ci/reporter/test_suite.rb', line 108 def assertions @assertions end |
#failures ⇒ Object
Returns the value of attribute failures.
109 110 111 |
# File 'lib/ci/reporter/test_suite.rb', line 109 def failures @failures end |
#name ⇒ Object
Returns the value of attribute name
108 109 110 |
# File 'lib/ci/reporter/test_suite.rb', line 108 def name @name end |
#time ⇒ Object
Returns the value of attribute time
108 109 110 |
# File 'lib/ci/reporter/test_suite.rb', line 108 def time @time end |
Instance Method Details
#error? ⇒ Boolean
Returns non-nil if the test had an error.
132 133 134 |
# File 'lib/ci/reporter/test_suite.rb', line 132 def error? !failures.empty? && failures.detect {|f| f.error? } end |
#failure? ⇒ Boolean
Returns non-nil if the test failed.
127 128 129 |
# File 'lib/ci/reporter/test_suite.rb', line 127 def failure? !failures.empty? && failures.detect {|f| f.failure? } end |
#finish ⇒ Object
Finishes timing the test.
122 123 124 |
# File 'lib/ci/reporter/test_suite.rb', line 122 def finish self.time = Time.now - @start end |
#start ⇒ Object
Starts timing the test.
117 118 119 |
# File 'lib/ci/reporter/test_suite.rb', line 117 def start @start = Time.now end |
#to_xml(builder) ⇒ Object
Writes xml representing the test result to the provided builder.
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/ci/reporter/test_suite.rb', line 137 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 failures.each do |failure| builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.)) do builder.text!(failure. + " (#{failure.name})\n") builder.text!(failure.location) end end end end |