Method: Inspec::Reporters::Junit#render

Defined in:
lib/inspec/reporters/junit.rb

#renderObject



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

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