Class: InspecPlugins::JUnitReporter::Reporter
- Inherits:
-
Object
- Object
- InspecPlugins::JUnitReporter::Reporter
- Defined in:
- lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #count_profile_errored_tests(profile) ⇒ Object
- #count_profile_failed_tests(profile) ⇒ Object
- #count_profile_skipped_tests(profile) ⇒ Object
- #count_profile_tests(profile) ⇒ Object
- #render ⇒ Object
Class Method Details
.run_data_schema_constraints ⇒ Object
3 4 5 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 3 def self.run_data_schema_constraints "~> 0.0" end |
Instance Method Details
#count_profile_errored_tests(profile) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 47 def count_profile_errored_tests(profile) profile.controls.reduce(0) do |acc, elem| acc + elem.results.reduce(0) do |err_test_total, test_case| test_case.backtrace.nil? ? err_test_total : err_test_total + 1 end end end |
#count_profile_failed_tests(profile) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 31 def count_profile_failed_tests(profile) profile.controls.reduce(0) do |acc, elem| acc + elem.results.reduce(0) do |fail_test_total, test_case| test_case.status == "failed" ? fail_test_total + 1 : fail_test_total end end end |
#count_profile_skipped_tests(profile) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 39 def count_profile_skipped_tests(profile) profile.controls.reduce(0) do |acc, elem| acc + elem.results.reduce(0) do |skip_test_total, test_case| test_case.status == "skipped" ? skip_test_total + 1 : skip_test_total end end end |
#count_profile_tests(profile) ⇒ Object
25 26 27 28 29 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 25 def count_profile_tests(profile) profile.controls.reduce(0) do |acc, elem| acc + elem.results.count end end |
#render ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/plugins/inspec-reporter-junit/lib/inspec-reporter-junit/reporter.rb', line 7 def render require "rexml/document" unless defined?(REXML::Document) xml_output = REXML::Document.new xml_output.add(REXML::XMLDecl.new) testsuites = REXML::Element.new("testsuites") xml_output.add(testsuites) run_data.profiles.each_with_index do |profile, idx| testsuites.add(build_profile_xml(profile, idx)) end formatter = REXML::Formatters::Pretty.new formatter.compact = true output(formatter.write(xml_output.xml_decl, "")) output(formatter.write(xml_output.root, "")) end |