Skip to content

Instantly share code, notes, and snippets.

@lucascs
Created June 7, 2010 13:22
Show Gist options
  • Save lucascs/428658 to your computer and use it in GitHub Desktop.
Save lucascs/428658 to your computer and use it in GitHub Desktop.
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