Class: Minitest::Queue::JUnitReporter
- Inherits:
-
Reporters::BaseReporter
- Object
- Reporters::BaseReporter
- Minitest::Queue::JUnitReporter
- Includes:
- CI::Queue::OutputHelpers
- Defined in:
- lib/minitest/queue/junit_reporter.rb
Instance Method Summary collapse
- #format_document(doc, io) ⇒ Object
- #generate_document ⇒ Object
-
#initialize(report_path = 'log/junit.xml', options = {}) ⇒ JUnitReporter
constructor
A new instance of JUnitReporter.
- #report ⇒ Object
Constructor Details
#initialize(report_path = 'log/junit.xml', options = {}) ⇒ JUnitReporter
Returns a new instance of JUnitReporter.
12 13 14 15 16 |
# File 'lib/minitest/queue/junit_reporter.rb', line 12 def initialize(report_path = 'log/junit.xml', = {}) super({}) @report_path = File.absolute_path(report_path) @base_path = [:base_path] || Dir.pwd end |
Instance Method Details
#format_document(doc, io) ⇒ Object
34 35 36 37 38 |
# File 'lib/minitest/queue/junit_reporter.rb', line 34 def format_document(doc, io) formatter = REXML::Formatters::Pretty.new formatter.write(doc, io) io << "\n" end |
#generate_document ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/minitest/queue/junit_reporter.rb', line 18 def generate_document suites = tests.group_by { |test| test.klass } doc = REXML::Document.new(nil, { :prologue_quote => :quote, :attribute_quote => :quote, }) doc << REXML::XMLDecl.new('1.1', 'utf-8') testsuites = doc.add_element('testsuites') suites.each do |suite, tests| add_tests_to(testsuites, suite, tests) end doc end |
#report ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/minitest/queue/junit_reporter.rb', line 40 def report super FileUtils.mkdir_p(File.dirname(@report_path)) File.open(@report_path, 'w+') do |file| format_document(generate_document, file) end end |