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 |
# File 'lib/report/junit_report.rb', line 15 def self.test_step_summary_xml(test_file_name, test_file_name_index) @testStepReportSummary2[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
27 28 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 65 66 67 |
# File 'lib/report/junit_report.rb', line 27 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' => $testSuiteFile.to_s, 'name' => $testSuiteFile.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| @testStepReportSummary2.each do |testStepReportSummary2| testsuites.testsuite(testStepReportSummary2) do |testsuite| $testStep_xml[testStepReportSummary2['name']].each do |testStepIndex, testStep_xml| testsuite.testcase(testStep_xml) do |testcase| failure = $failtestStep_xml&.[](testStepReportSummary2['name'])&.[](testStepIndex) skipped = $skiptestStep_xml&.[](testStepReportSummary2['name'])&.[](testStepIndex) testcase.failure(failure) if failure testcase.skipped(skipped) if skipped end end end end end end # output XML content to console for debug # puts builder.to_xml # open the suite summary file for writing if not already open if !File.exist?($TestSuiteSummaryXML) || $TestSuiteSummaryXML.closed? $testSuiteSummaryFile_xml = File.open($TestSuiteSummaryXML, 'w+') $testSuiteSummaryFile_xml.write builder.to_xml elsif $log.puts "test suite summary file xml name: #{$TestSuiteSummaryXML} is already open" end # if the file is open then close it $testSuiteSummaryFile_xml.close unless $testSuiteSummaryFile_xml.closed? end |