Class: Inspec::Reporters::Junit

Inherits:
Base
  • Object
show all
Defined in:
lib/inspec/reporters/junit.rb

Instance Attribute Summary

Attributes inherited from Base

#run_data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #output, #rendered_output

Constructor Details

This class inherits a constructor from Inspec::Reporters::Base

Instance Method Details

#renderObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/inspec/reporters/junit.rb', line 5

def render
  require '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 do |profile|
    testsuites.add(build_profile_xml(profile))
  end

  formatter = REXML::Formatters::Pretty.new
  formatter.compact = true
  output(formatter.write(xml_output.xml_decl, ''))
  output(formatter.write(xml_output.root, ''))
end