Class: Minitest::Queue::JUnitReporter
- Inherits:
-
Reporters::BaseReporter
- Object
- Reporters::BaseReporter
- Minitest::Queue::JUnitReporter
- 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.
10 11 12 13 14 |
# File 'lib/minitest/queue/junit_reporter.rb', line 10 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
32 33 34 35 36 |
# File 'lib/minitest/queue/junit_reporter.rb', line 32 def format_document(doc, io) formatter = REXML::Formatters::Pretty.new formatter.write(doc, io) io << "\n" end |
#generate_document ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/minitest/queue/junit_reporter.rb', line 16 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
38 39 40 41 42 43 44 45 |
# File 'lib/minitest/queue/junit_reporter.rb', line 38 def report super FileUtils.mkdir_p(File.dirname(@report_path)) File.open(@report_path, 'w+') do |file| format_document(generate_document, file) end end |