Class: TestCenter::Helper::HtmlTestReport::TestSuite
- Inherits:
-
Object
- Object
- TestCenter::Helper::HtmlTestReport::TestSuite
- 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
- #add_testcase(testcase) ⇒ Object
- #collate_testsuite(testsuite) ⇒ Object
- #duplicate_testcases? ⇒ Boolean
-
#initialize(testsuite_element) ⇒ TestSuite
constructor
A new instance of TestSuite.
- #passing? ⇒ Boolean
- #remove_duplicate_testcases ⇒ Object
- #set_passing(status) ⇒ Object
- #testcase_with_title(title) ⇒ Object
- #testcases ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(testsuite_element) ⇒ TestSuite
Returns a new instance of TestSuite.
130 131 132 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 130 def initialize(testsuite_element) @root = testsuite_element end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
128 129 130 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 128 def root @root end |
Instance Method Details
#add_testcase(testcase) ⇒ Object
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 163 def add_testcase(testcase) tests_table = REXML::XPath.first(@root, ".//*[contains(@class, 'tests')]/table") details = testcase.failure_details if details tests_table.push(details) tests_table.insert_before(details, testcase.root) else tests_table.push(testcase.root) end end |
#collate_testsuite(testsuite) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 190 def collate_testsuite(testsuite) given_testcases = testsuite.testcases given_testcases.each do |given_testcase| existing_testcase = testcase_with_title(given_testcase.title) if existing_testcase.nil? FastlaneCore::UI.verbose("\t\tadding testcase\n\t\t\t#{given_testcase.root}") unless given_testcase.passing? FastlaneCore::UI.verbose("\t\t\twith failure:\n\t\t\t\t#{given_testcase.failure_details}") end add_testcase(given_testcase) else FastlaneCore::UI.verbose("\t\tupdating testcase\n\t\t\t#{existing_testcase.root}") unless given_testcase.passing? FastlaneCore::UI.verbose("\t\t\twith failure:\n\t\t\t\t#{given_testcase.failure_details}") end existing_testcase.update_testcase(given_testcase) end end set_passing(testcases.all?(&:passing?)) end |
#duplicate_testcases? ⇒ Boolean
174 175 176 177 178 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 174 def duplicate_testcases? nonuniq_testcases = testcases uniq_testcases = nonuniq_testcases.uniq { |tc| tc.title } nonuniq_testcases != uniq_testcases end |
#passing? ⇒ Boolean
150 151 152 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 150 def passing? @root.attribute('class').value.include?('passing') end |
#remove_duplicate_testcases ⇒ Object
180 181 182 183 184 185 186 187 188 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 180 def remove_duplicate_testcases nonuniq_testcases = testcases uniq_testcases = nonuniq_testcases.uniq { |tc| tc.title } (nonuniq_testcases - uniq_testcases).each do |tc| failure_details = tc.failure_details tc.root.parent.delete_element(failure_details) tc.root.parent.delete_element(tc.root) end end |
#set_passing(status) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 154 def set_passing(status) desired_status = status ? ' passing ' : ' failing ' to_replace = status ? /\bfailing\b/ : /\bpassing\b/ attribute = @root.attribute('class').value.sub(to_replace, desired_status) attribute.gsub!(/\s{2,}/, ' ') @root.add_attribute('class', attribute) end |
#testcase_with_title(title) ⇒ Object
145 146 147 148 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 145 def testcase_with_title(title) testcase_element = REXML::XPath.first(@root, ".//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]//*[@class='title']/[normalize-space()='#{title}']/../../..") TestCase.new(testcase_element) unless testcase_element.nil? end |
#testcases ⇒ Object
138 139 140 141 142 143 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 138 def testcases testcase_elements = REXML::XPath.match(@root, ".//*[contains(@class, 'tests')]//*[contains(concat(' ', @class, ' '), ' test ')]") testcase_elements.map do |testcase_element| TestCase.new(testcase_element) end end |
#title ⇒ Object
134 135 136 |
# File 'lib/fastlane/plugin/test_center/helper/html_test_report.rb', line 134 def title @root.attribute('id').value end |