Class: TestCenter::Helper::HtmlTestReport::TestCase
- Inherits:
-
Object
- Object
- TestCenter::Helper::HtmlTestReport::TestCase
- Defined in:
- lib/fastlane/plugin/test_center/helper/html_test_report.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #failure_details ⇒ Object
-
#initialize(testcase_element) ⇒ TestCase
constructor
A new instance of TestCase.
- #passing? ⇒ Boolean
- #remove_failure_details ⇒ Object
- #row_color ⇒ Object
- #set_row_color(row_color) ⇒ Object
- #title ⇒ Object
- #update_testcase(testcase) ⇒ Object
Constructor Details
#initialize(testcase_element) ⇒ TestCase
Returns a new instance of TestCase.
233 234 235 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 233 def initialize(testcase_element) @root = testcase_element end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
231 232 233 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 231 def root @root end |
Instance Method Details
#failure_details ⇒ Object
256 257 258 259 260 261 262 263 264 265 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 256 def failure_details return nil if @root.attribute('class').value.include?('passing') xpath_class_attributes = [ "contains(concat(' ', @class, ' '), ' details ')", "contains(concat(' ', @class, ' '), ' failing ')", "contains(concat(' ', @class, ' '), ' #{title} ')" ].join(' and ') REXML::XPath.first(@root.parent, ".//*[#{xpath_class_attributes}]") end |
#passing? ⇒ Boolean
241 242 243 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 241 def passing? @root.attribute('class').value.include?('passing') end |
#remove_failure_details ⇒ Object
267 268 269 270 271 272 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 267 def remove_failure_details details = failure_details return if details.nil? details.parent.delete_element(details) end |
#row_color ⇒ Object
245 246 247 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 245 def row_color @root.attribute('class').value.include?('odd') ? 'odd' : '' end |
#set_row_color(row_color) ⇒ Object
249 250 251 252 253 254 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 249 def set_row_color(row_color) raise 'row_color must either be "odd" or ""' unless ['odd', ''].include?(row_color) current_class_attribute = @root.attribute('class').value.sub(/\bodd\b/, '') @root.add_attribute('class', current_class_attribute << ' ' << row_color) end |
#title ⇒ Object
237 238 239 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 237 def title REXML::XPath.first(@root, ".//h3[contains(@class, 'title')]/text()").to_s.strip end |
#update_testcase(testcase) ⇒ Object
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 274 def update_testcase(testcase) color = row_color failure = failure_details if failure.nil? && !passing? FastlaneCore::UI.error("\t\t\t\tupdating failing test case that does not have failure_details") end parent = @root.parent failure.parent.delete(failure) unless failure.nil? new_failure = testcase.failure_details if new_failure && testcase.passing? FastlaneCore::UI.error("\t\t\t\tswapping passing failing test case that _does_have_ failure_details") end parent.replace_child(@root, testcase.root) @root = testcase.root unless new_failure.nil? parent.insert_after(@root, new_failure) end set_row_color(color) end |