Class: Scanny::Reporters::XMLReporter
- Defined in:
- lib/scanny/reporters/xml_reporter.rb
Instance Attribute Summary
Attributes inherited from Reporter
#checks_performed, #file, #issues, #nodes_inspected
Instance Method Summary collapse
-
#initialize ⇒ XMLReporter
constructor
A new instance of XMLReporter.
- #report ⇒ Object
Constructor Details
#initialize ⇒ XMLReporter
Returns a new instance of XMLReporter.
8 9 10 11 |
# File 'lib/scanny/reporters/xml_reporter.rb', line 8 def initialize(*) prepare_reports_directory super end |
Instance Method Details
#report ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scanny/reporters/xml_reporter.rb', line 13 def report out = "" doc = REXML::Document.new testsuite = REXML::Element.new("testsuite") testsuite.add_attributes('assertions' => nodes_inspected.to_s, 'errors' => issues.size.to_s, 'skipped' => '0', 'tests' => checks_performed.to_s, 'failures' => '0', 'name' => file) #TODO: track time? issues.each do |issue| testcase = REXML::Element.new 'testcase' testcase.add_attributes("name" => "#{issue.file}:#{issue.line}") error = REXML::Element.new 'error' error.add_attributes('type' => issue.impact.to_s, 'message' => issue.) error.text = issue.to_s testcase.add_element error testsuite.add_element testcase end testsuite.add_element REXML::Element.new("system-out") testsuite.add_element REXML::Element.new("system-err") doc << testsuite doc.write(out, 2) File.open(output, "w") { |f| f.write(out) } out end |