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
47
48
49
|
# File 'lib/xcode/test/formatters/junit_formatter.rb', line 17
def write(report)
if report.end_time.nil?
raise "Report #{report} #{report.name} has a nil end time!?"
end
xml = ::Builder::XmlMarkup.new( :indent => 2 )
xml.instruct! :xml, :encoding => "UTF-8"
xml.testsuite(:errors => report.total_errors,
:failures => report.total_failed_tests,
:hostname => Socket.gethostname,
:name => report.name,
:tests => report.tests.count,
:time => (report.end_time - report.start_time),
:timestamp => report.end_time
) do |p|
report.tests.each do |t|
p.testcase(:classname => report.name,
:name => t.name,
:time => t.time
) do |testcase|
t.errors.each do |error|
testcase.failure error[:location], :message => error[:message], :type => 'Failure'
end
end
end
end
File.open(File.join(@dir, sanitize_filename("TEST-#{report.name}.xml")), 'w') do |current_file|
current_file.write xml.target!
end
end
|