Class: CI::Reporter::TestCase
- Inherits:
-
Struct
- Object
- Struct
- CI::Reporter::TestCase
- Includes:
- StructureXmlHelpers
- 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.
- #error_count ⇒ Object
-
#failure? ⇒ Boolean
Returns non-nil if the test failed.
- #failure_count ⇒ Object
-
#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.
Methods included from StructureXmlHelpers
#attr_hash, #cleaned_attributes, #truncate_at_newline
Constructor Details
#initialize(*args) ⇒ TestCase
Returns a new instance of TestCase.
91 92 93 94 |
# File 'lib/ci/reporter/test_suite.rb', line 91 def initialize(*args) super @failures = [] end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions
85 86 87 |
# File 'lib/ci/reporter/test_suite.rb', line 85 def assertions @assertions end |
#failures ⇒ Object
Returns the value of attribute failures.
88 89 90 |
# File 'lib/ci/reporter/test_suite.rb', line 88 def failures @failures end |
#name ⇒ Object
Returns the value of attribute name
85 86 87 |
# File 'lib/ci/reporter/test_suite.rb', line 85 def name @name end |
#skipped ⇒ Object
Returns the value of attribute skipped.
89 90 91 |
# File 'lib/ci/reporter/test_suite.rb', line 89 def skipped @skipped end |
#time ⇒ Object
Returns the value of attribute time
85 86 87 |
# File 'lib/ci/reporter/test_suite.rb', line 85 def time @time end |
Instance Method Details
#error? ⇒ Boolean
Returns non-nil if the test had an error.
112 113 114 |
# File 'lib/ci/reporter/test_suite.rb', line 112 def error? failures.any?(&:error?) end |
#error_count ⇒ Object
120 121 122 |
# File 'lib/ci/reporter/test_suite.rb', line 120 def error_count failures.count(&:error?) end |
#failure? ⇒ Boolean
Returns non-nil if the test failed.
107 108 109 |
# File 'lib/ci/reporter/test_suite.rb', line 107 def failure? failures.any?(&:failure?) end |
#failure_count ⇒ Object
116 117 118 |
# File 'lib/ci/reporter/test_suite.rb', line 116 def failure_count failures.count(&:failure?) end |
#finish ⇒ Object
Finishes timing the test.
102 103 104 |
# File 'lib/ci/reporter/test_suite.rb', line 102 def finish self.time = MonotonicTime.time_in_seconds - @start end |
#skipped? ⇒ Boolean
124 125 126 |
# File 'lib/ci/reporter/test_suite.rb', line 124 def skipped? skipped end |
#start ⇒ Object
Starts timing the test.
97 98 99 |
# File 'lib/ci/reporter/test_suite.rb', line 97 def start @start = MonotonicTime.time_in_seconds end |
#to_xml(builder) ⇒ Object
Writes xml representing the test result to the provided builder.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# 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.)) do builder.text!(failure. + " (#{failure.name})\n") builder.text!(failure.location) end end end end end |