Class: PuppetCatalogTest::JunitXmlReporter
- Inherits:
-
StdoutReporter
- Object
- StdoutReporter
- PuppetCatalogTest::JunitXmlReporter
- Defined in:
- lib/puppet-catalog-test/junit_xml_reporter.rb
Instance Method Summary collapse
-
#initialize(project_name, report_file) ⇒ JunitXmlReporter
constructor
A new instance of JunitXmlReporter.
- #summarize(tr) ⇒ Object
Methods inherited from StdoutReporter
#report_failed_test_case, #report_passed_test_case
Constructor Details
#initialize(project_name, report_file) ⇒ JunitXmlReporter
Returns a new instance of JunitXmlReporter.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/puppet-catalog-test/junit_xml_reporter.rb', line 5 def initialize(project_name, report_file) @project_name = project_name @report_file = report_file target_dir = File.dirname(report_file) FileUtils.mkdir_p(target_dir) @out = $stdout end |
Instance Method Details
#summarize(tr) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet-catalog-test/junit_xml_reporter.rb', line 16 def summarize(tr) failed_nodes = tr.test_cases.select { |tc| tc.passed == false } builder = Builder::XmlMarkup.new xml = builder.testsuite(:failures => failed_nodes.size, :tests => tr.test_cases.size) do |ts| tr.test_cases.each do |tc| ts.testcase(:classname => @project_name, :name => tc.name, :time => tc.duration) do |tc_node| if tc.error tc_node.failure tc.error end end end end File.open(@report_file, "w") do |fp| fp.puts xml end end |