Skip to content

Instantly share code, notes, and snippets.

@lucascs
Created Jun 7, 2010
Embed
What would you like to do?
post '/junit-results' do
result = JSON.parse(request.body.read)
passes = result['stats']['passes']
failures = result['stats']['failures']
File.open(File.dirname(__FILE__) + '/../../target/artifacts/reports/javascript.xml', 'w') do |f|
xml = Builder::XmlMarkup.new
suite = xml.testsuite :errors => 0, :failures => failures, :tests => passes, :name => "javascript.tests" do
result['results'].each do |tc|
unless tc.nil?
tc['specs'].each do |s|
xml.testcase :classname => tc['description'], :name => s['description'] do
if s['status'] != 'pass'
xml.failure s['assertions'].inspect, :message => s['assertions'].inspect
end
end
end
end
end
end
f.write suite
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment