class TestCenter::Helper::HtmlTestReport::Report
Attributes
root[R]
Public Class Methods
new(html_file)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 21 def initialize(html_file) @root = html_file.root end
Public Instance Methods
add_testsuite(testsuite)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 32 def add_testsuite(testsuite) testsuites_element = REXML::XPath.first(@root, ".//*[@id='test-suites']") testsuites_element.push(testsuite.root) end
collate_report(report)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 37 def collate_report(report) testsuites.each(&:remove_duplicate_testcases) report.testsuites.each(&:remove_duplicate_testcases) HtmlTestReport.verbose("TestCenter::Helper::HtmlTestReport::Report.collate_report to report:\n\t#{@root}") report.testsuites.each do |given_testsuite| existing_testsuite = testsuite_with_title(given_testsuite.title) if existing_testsuite.nil? HtmlTestReport.verbose("\tadding testsuite\n\t\t#{given_testsuite}") add_testsuite(given_testsuite) else HtmlTestReport.verbose("\tcollating testsuite\n\t\t#{given_testsuite.root}") existing_testsuite.collate_testsuite(given_testsuite) HtmlTestReport.verbose("\tafter collation exiting testsuite\n\t\t#{existing_testsuite.root}") end end update_test_count update_fail_count end
fail_count()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 75 def fail_count fail_count_element = REXML::XPath.first(@root, ".//*[@id = 'counters']//*[@id='fail-count']/*[@class = 'number']/text()") return fail_count_element.to_s.to_i if fail_count_element return 0 end
save_report(report_path)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 127 def save_report(report_path) add_test_center_footer output = '' formatter = REXML::Formatters::Transitive.new formatter.write(@root, output) File.open(report_path, 'w') do |f| f.puts output end end
set_fail_count(fail_count)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 81 def set_fail_count(fail_count) counters_element = REXML::XPath.first(@root, ".//*[@id = 'counters']") fail_count_number_element = REXML::XPath.first(counters_element, ".//*[@id='fail-count']/*[@class = 'number']/text()") if fail_count_number_element fail_count_number_element.value = fail_count.to_s else test_count_element = REXML::XPath.first(counters_element, ".//*[@id='test-count']") fail_count_element = test_count_element.clone fail_count_element.add_attribute('id', 'fail-count') test_count_element.each_element do |element| fail_count_element.add_element(element.clone) end REXML::XPath.first(fail_count_element, ".//*[@class = 'number']").text = fail_count counters_element.add_element(fail_count_element) end end
set_test_count(test_count)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 65 def set_test_count(test_count) test_count_element = REXML::XPath.first(@root, ".//*[@id = 'counters']//*[@id='test-count']/*[@class = 'number']/text()") test_count_element.value = test_count.to_s end
test_count()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 61 def test_count REXML::XPath.first(@root, ".//*[@id = 'counters']//*[@id='test-count']/*[@class = 'number']/text()").to_s.to_i end
testsuite_with_title(title)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 56 def testsuite_with_title(title) testsuite_element = REXML::XPath.first(@root, ".//*[contains(@id, 'test-suites')]//*[@id='#{title}' and contains(concat(' ', @class, ' '), ' test-suite ')]") TestSuite.new(testsuite_element) unless testsuite_element.nil? end
testsuites()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 25 def testsuites testsuite_elements = REXML::XPath.match(@root, "//section[contains(@class, 'test-suite')]") testsuite_elements.map do |testsuite_element| TestSuite.new(testsuite_element) end end
update_fail_count()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 99 def update_fail_count xpath_class_attributes = [ "contains(concat(' ', @class, ' '), ' test ')", "contains(concat(' ', @class, ' '), ' failing ')" ].join(' and ') failing_testcase_elements = REXML::XPath.match(@root, ".//*[#{xpath_class_attributes}]") set_fail_count(failing_testcase_elements.size) end
update_test_count()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/html_test_report.rb, line 70 def update_test_count testcase_elements = REXML::XPath.match(@root, "//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]").uniq set_test_count(testcase_elements.size) end