Module: JunitReport
- Defined in:
- lib/report/junit_report.rb
Overview
Created on 20 Sept 2017 @author: Andy Perrett
Versions: 1.0 - Baseline
junit_report.rb - methods for writing to the summary xml junit report.
Class Method Summary collapse
-
.test_step_summary_xml(test_file_name, test_file_name_index) ⇒ Object
construct the test suite header for junit.
- .test_summary_junit ⇒ Object
Class Method Details
.test_step_summary_xml(test_file_name, test_file_name_index) ⇒ Object
construct the test suite header for junit
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/report/junit_report.rb', line 15 def self.test_step_summary_xml(test_file_name, test_file_name_index) @test_step_report_summary2[test_file_name_index] = { 'classname' => test_file_name, 'name' => test_file_name, 'assertions' => $numberOfTestSteps, 'failures' => $testStepFailures, 'tests' => $testStepPasses, 'skipped' => $testStepNotrun, 'time' => TimeDifference.between( $test_case_end_time, $test_case_start_time ).in_seconds } end |
.test_summary_junit ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/report/junit_report.rb', line 29 def self.test_summary_junit # output to XML file format for Junit for CI. builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| testsuite_attrs = { 'classname' => $testcasesFolder.to_s, 'name' => $testcasesFolder.to_s, 'tests' => $totalTests.to_s, 'failures' => $totalTestFailures.to_s, 'timestamp' => $test_start_time.to_s, 'skipped' => $totalTestNotrun.to_s, 'time' => TimeDifference.between($test_end_time, $test_start_time) .in_seconds } xml.testsuites(testsuite_attrs) do |testsuites| @test_step_report_summary2.each do |test_step_report_summary2| testsuites.testsuite(test_step_report_summary2) do |testsuite| $testStep_xml[test_step_report_summary2['name']] .each do |test_step_idx, test_step_xml| testsuite.testcase(test_step_xml) do |testcase| failure = $failtestStep_xml &.[](test_step_report_summary2['name'])&.[](test_step_idx) skipped = $skiptestStep_xml &.[](test_step_report_summary2['name'])&.[](test_step_idx) testcase.failure(failure) if failure testcase.skipped(skipped) if skipped end end end end end end ts_summary_file_xml = File.open($TestSuiteSummaryXML, 'w') ts_summary_file_xml.write builder.to_xml ts_summary_file_xml.close end |