Sha256: d02d0de2d66aab070ef3843141960d7ab1e5a439f9fbb4937fe4f150169b514a
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require 'time' # Dumps rspec results as a JUnit XML file. # Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd class RSpec::Core::Formatters::JUnitFormatter < RSpec::Core::Formatters::BaseFormatter def xml @xml ||= Builder::XmlMarkup.new :target => output, :indent => 2 end def start example_count @start = Time.now super end def dump_summary duration, example_count, failure_count, pending_count super xml.instruct! xml.testsuite :tests => example_count, :failures => failure_count, :errors => 0, :time => '%.6f' % duration, :timestamp => @start.iso8601 do xml.properties examples.each do |example| send :"dump_summary_example_#{example.execution_result[:status]}", example end end end def xml_example example, &block xml.testcase :classname => example_classname(example), :name => example.full_description, :time => '%.6f' % example.execution_result[:run_time], &block end def dump_summary_example_passed example xml_example example end def dump_summary_example_pending example xml_example example do xml.skipped end end def dump_summary_example_failed example exception = example.execution_result[:exception] backtrace = format_backtrace exception.backtrace, example xml_example example do xml.error message: exception.to_s, type: exception.class.name do xml.text! "#{exception.message.encode(:xml => :text)}\n#{backtrace.join.encode(:xml => :text)}" end end end def example_classname example example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec_junit_formatter_jenkins-0.1.6 | lib/rspec/core/formatters/j_unit_formatter.rb |