Skip to content

Commit

Permalink
Merge pull request #600 from lukzeg/feature/sync_with_junit_for_jenkins
Browse files Browse the repository at this point in the history
Fix the junit_test_reporter to fit Ant and Surfire test schema
  • Loading branch information
mvandervoord authored May 31, 2021
2 parents 7d463ab + 6933881 commit 069c9c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/junit_tests_report/lib/junit_tests_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def post_build
def write_header( results, stream )
results[:counts][:time] = @time_result.reduce(0, :+)
stream.puts '<?xml version="1.0" encoding="utf-8" ?>'
stream.puts('<testsuites tests="%<total>d" failures="%<failed>d" skipped="%<ignored>d" time="%<time>f">' % results[:counts])
stream.puts('<testsuites tests="%<total>d" failures="%<failed>d" time="%<time>.3f">' % results[:counts])
end

def write_footer( stream )
Expand All @@ -53,7 +53,7 @@ def write_footer( stream )

def reorganise_results( results )
# Reorganise the output by test suite instead of by result
suites = Hash.new{ |h,k| h[k] = {collection: [], total: 0, success: 0, failed: 0, ignored: 0, stdout: []} }
suites = Hash.new{ |h,k| h[k] = {collection: [], total: 0, success: 0, failed: 0, ignored: 0, errors: 0, stdout: []} }
results[:successes].each do |result|
source = result[:source]
name = source[:file].sub(/\..{1,4}$/, "")
Expand Down Expand Up @@ -85,7 +85,7 @@ def reorganise_results( results )

def write_suite( suite, stream )
suite[:time] = @time_result.shift
stream.puts(' <testsuite name="%<name>s" tests="%<total>d" failures="%<failed>d" skipped="%<ignored>d" time="%<time>f">' % suite)
stream.puts(' <testsuite name="%<name>s" tests="%<total>d" failures="%<failed>d" skipped="%<ignored>d" errors="%<errors>d" time="%<time>.3f">' % suite)

suite[:collection].each do |test|
write_test( test, stream )
Expand Down Expand Up @@ -116,17 +116,17 @@ def write_test( test, stream )

case test[:result]
when :success
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>f"/>' % test)
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>.3f"/>' % test)
when :failed
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>f">' % test)
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>.3f">' % test)
if test[:message].empty?
stream.puts(' <failure />')
else
stream.puts(' <failure message="%s" />' % test[:message])
end
stream.puts(' </testcase>')
when :ignored
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>f">' % test)
stream.puts(' <testcase name="%<test>s" time="%<unity_test_time>.3f">' % test)
stream.puts(' <skipped />')
stream.puts(' </testcase>')
end
Expand Down

0 comments on commit 069c9c2

Please sign in to comment.