mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-05 21:18:08 -05:00
junit: Include output in JUnit report for successful tests and benchmarks
This commit is contained in:
parent
a4c479dbbb
commit
d2592490b6
@ -178,6 +178,8 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites {
|
|||||||
Message: "No test result found",
|
Message: "No test result found",
|
||||||
Data: formatOutput(test.Output, test.Level),
|
Data: formatOutput(test.Output, test.Level),
|
||||||
}
|
}
|
||||||
|
} else if len(test.Output) > 0 {
|
||||||
|
tc.SystemOut = &Output{Data: formatOutput(test.Output, test.Level)}
|
||||||
}
|
}
|
||||||
|
|
||||||
suite.AddTestcase(tc)
|
suite.AddTestcase(tc)
|
||||||
@ -198,6 +200,8 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites {
|
|||||||
tc.Skipped = &Result{
|
tc.Skipped = &Result{
|
||||||
Message: "Skipped",
|
Message: "Skipped",
|
||||||
}
|
}
|
||||||
|
} else if len(bm.Output) > 0 {
|
||||||
|
tc.SystemOut = &Output{Data: formatOutput(bm.Output, 0)}
|
||||||
}
|
}
|
||||||
|
|
||||||
suite.AddTestcase(tc)
|
suite.AddTestcase(tc)
|
||||||
|
7
testdata/001-report.xml
vendored
7
testdata/001-report.xml
vendored
@ -5,7 +5,12 @@
|
|||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestPass" classname="package/pass" time="0.060"></testcase>
|
<testcase name="TestPass" classname="package/pass" time="0.060"></testcase>
|
||||||
<testcase name="TestPassLog" classname="package/pass" time="0.100"></testcase>
|
<testcase name="TestPassLog" classname="package/pass" time="0.100">
|
||||||
|
<system-out><![CDATA[ pass_test.go:9: log line
|
||||||
|
pass_test.go:10: log
|
||||||
|
multi
|
||||||
|
line]]></system-out>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="package/fail" tests="1" failures="1" errors="0" hostname="hostname" time="0.151" timestamp="2022-01-01T00:00:00Z">
|
<testsuite name="package/fail" tests="1" failures="1" errors="0" hostname="hostname" time="0.151" timestamp="2022-01-01T00:00:00Z">
|
||||||
<properties>
|
<properties>
|
||||||
|
7
testdata/005-report.xml
vendored
7
testdata/005-report.xml
vendored
@ -4,6 +4,11 @@
|
|||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestPass" classname="package/pass" time="0.060"></testcase>
|
<testcase name="TestPass" classname="package/pass" time="0.060"></testcase>
|
||||||
<testcase name="TestPassLog" classname="package/pass" time="0.100"></testcase>
|
<testcase name="TestPassLog" classname="package/pass" time="0.100">
|
||||||
|
<system-out><![CDATA[ pass_test.go:9: log line
|
||||||
|
pass_test.go:10: log
|
||||||
|
multi
|
||||||
|
line]]></system-out>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
8
testdata/012-report.xml
vendored
8
testdata/012-report.xml
vendored
@ -7,7 +7,9 @@
|
|||||||
<testcase name="TestSubtests" classname="package/subtests" time="0.000">
|
<testcase name="TestSubtests" classname="package/subtests" time="0.000">
|
||||||
<failure message="Failed"></failure>
|
<failure message="Failed"></failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase name="TestSubtests/Subtest" classname="package/subtests" time="0.000"></testcase>
|
<testcase name="TestSubtests/Subtest" classname="package/subtests" time="0.000">
|
||||||
|
<system-out><![CDATA[ subtests_test.go:7: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="TestSubtests/Subtest#01" classname="package/subtests" time="0.000">
|
<testcase name="TestSubtests/Subtest#01" classname="package/subtests" time="0.000">
|
||||||
<failure message="Failed"><![CDATA[ subtests_test.go:10: error message]]></failure>
|
<failure message="Failed"><![CDATA[ subtests_test.go:10: error message]]></failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
@ -24,7 +26,9 @@
|
|||||||
<testcase name="TestFailingSubtestWithNestedSubtest/Subtest" classname="package/subtests" time="0.000">
|
<testcase name="TestFailingSubtestWithNestedSubtest/Subtest" classname="package/subtests" time="0.000">
|
||||||
<failure message="Failed"><![CDATA[ subtests_test.go:31: Subtest error message]]></failure>
|
<failure message="Failed"><![CDATA[ subtests_test.go:31: Subtest error message]]></failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase name="TestFailingSubtestWithNestedSubtest/Subtest/Subsubtest" classname="package/subtests" time="0.000"></testcase>
|
<testcase name="TestFailingSubtestWithNestedSubtest/Subtest/Subsubtest" classname="package/subtests" time="0.000">
|
||||||
|
<system-out><![CDATA[ subtests_test.go:29: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
<system-out><![CDATA[exit status 1]]></system-out>
|
<system-out><![CDATA[exit status 1]]></system-out>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
4
testdata/019-report.xml
vendored
4
testdata/019-report.xml
vendored
@ -4,7 +4,9 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestZ" classname="package/name" time="0.060"></testcase>
|
<testcase name="TestZ" classname="package/name" time="0.060">
|
||||||
|
<system-out><![CDATA[some inline text]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="TestA" classname="package/name" time="0.100"></testcase>
|
<testcase name="TestA" classname="package/name" time="0.100"></testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
50
testdata/030-report.xml
vendored
50
testdata/030-report.xml
vendored
@ -29,9 +29,28 @@ single-line stdout]]></failure>
|
|||||||
<testcase name="TestFailWithNoTestOutput" classname="package/stdout" time="0.000">
|
<testcase name="TestFailWithNoTestOutput" classname="package/stdout" time="0.000">
|
||||||
<failure message="Failed"></failure>
|
<failure message="Failed"></failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase name="TestPassWithStdoutAndTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<testcase name="TestPassWithStdoutAndTestOutput" classname="package/stdout" time="0.000">
|
||||||
<testcase name="TestPassWithStdoutAndNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<system-out><![CDATA[multi
|
||||||
<testcase name="TestPassWithTestOutput" classname="package/stdout" time="0.000"></testcase>
|
line
|
||||||
|
stdout
|
||||||
|
single-line stdout
|
||||||
|
stdout_test.go:33: single-line info
|
||||||
|
stdout_test.go:34: multi
|
||||||
|
line
|
||||||
|
info]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestPassWithStdoutAndNoTestOutput" classname="package/stdout" time="0.000">
|
||||||
|
<system-out><![CDATA[multi
|
||||||
|
line
|
||||||
|
stdout
|
||||||
|
single-line stdout]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestPassWithTestOutput" classname="package/stdout" time="0.000">
|
||||||
|
<system-out><![CDATA[ stdout_test.go:43: single-line info
|
||||||
|
stdout_test.go:44: multi
|
||||||
|
line
|
||||||
|
info]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="TestPassWithNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<testcase name="TestPassWithNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
||||||
<testcase name="TestSubtests" classname="package/stdout" time="0.000">
|
<testcase name="TestSubtests" classname="package/stdout" time="0.000">
|
||||||
<failure message="Failed"></failure>
|
<failure message="Failed"></failure>
|
||||||
@ -61,9 +80,28 @@ single-line stdout]]></failure>
|
|||||||
<testcase name="TestSubtests/TestFailWithNoTestOutput" classname="package/stdout" time="0.000">
|
<testcase name="TestSubtests/TestFailWithNoTestOutput" classname="package/stdout" time="0.000">
|
||||||
<failure message="Failed"></failure>
|
<failure message="Failed"></failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase name="TestSubtests/TestPassWithStdoutAndTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<testcase name="TestSubtests/TestPassWithStdoutAndTestOutput" classname="package/stdout" time="0.000">
|
||||||
<testcase name="TestSubtests/TestPassWithStdoutAndNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<system-out><![CDATA[multi
|
||||||
<testcase name="TestSubtests/TestPassWithTestOutput" classname="package/stdout" time="0.000"></testcase>
|
line
|
||||||
|
stdout
|
||||||
|
single-line stdout
|
||||||
|
stdout_test.go:33: single-line info
|
||||||
|
stdout_test.go:34: multi
|
||||||
|
line
|
||||||
|
info]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestSubtests/TestPassWithStdoutAndNoTestOutput" classname="package/stdout" time="0.000">
|
||||||
|
<system-out><![CDATA[multi
|
||||||
|
line
|
||||||
|
stdout
|
||||||
|
single-line stdout]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestSubtests/TestPassWithTestOutput" classname="package/stdout" time="0.000">
|
||||||
|
<system-out><![CDATA[ stdout_test.go:43: single-line info
|
||||||
|
stdout_test.go:44: multi
|
||||||
|
line
|
||||||
|
info]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="TestSubtests/TestPassWithNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
<testcase name="TestSubtests/TestPassWithNoTestOutput" classname="package/stdout" time="0.000"></testcase>
|
||||||
<system-out><![CDATA[exit status 1]]></system-out>
|
<system-out><![CDATA[exit status 1]]></system-out>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
92
testdata/035-report.xml
vendored
92
testdata/035-report.xml
vendored
@ -4,14 +4,90 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestFlat" classname="package/whitespace" time="0.000"></testcase>
|
<testcase name="TestFlat" classname="package/whitespace" time="0.000">
|
||||||
<testcase name="TestWithSpace" classname="package/whitespace" time="0.000"></testcase>
|
<system-out><![CDATA[ whitespace_test.go:9: log 1
|
||||||
<testcase name="TestWithTab" classname="package/whitespace" time="0.000"></testcase>
|
whitespace_test.go:10: log 2
|
||||||
<testcase name="TestWithNewlinesFlat" classname="package/whitespace" time="0.000"></testcase>
|
printf 1
|
||||||
|
printf 2]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestWithSpace" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:16: no-space
|
||||||
|
whitespace_test.go:17: one-space
|
||||||
|
whitespace_test.go:18: two-space
|
||||||
|
whitespace_test.go:19: four-space
|
||||||
|
whitespace_test.go:20: eight-space
|
||||||
|
whitespace_test.go:21: no-space
|
||||||
|
no-space
|
||||||
|
one-space
|
||||||
|
two-space
|
||||||
|
four-space
|
||||||
|
eight-space
|
||||||
|
no-space]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestWithTab" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:31: no-tab
|
||||||
|
whitespace_test.go:32: one-tab
|
||||||
|
whitespace_test.go:33: two-tab
|
||||||
|
no-tab
|
||||||
|
one-tab
|
||||||
|
two-tab]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestWithNewlinesFlat" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:40: no-newline
|
||||||
|
whitespace_test.go:41: one-newline
|
||||||
|
one-newline
|
||||||
|
whitespace_test.go:42: two-newlines
|
||||||
|
two-newlines
|
||||||
|
two-newlines
|
||||||
|
no-newline
|
||||||
|
one-newline
|
||||||
|
one-newline
|
||||||
|
two-newlines
|
||||||
|
two-newlines
|
||||||
|
two-newlines]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="TestSubTests" classname="package/whitespace" time="0.000"></testcase>
|
<testcase name="TestSubTests" classname="package/whitespace" time="0.000"></testcase>
|
||||||
<testcase name="TestSubTests/TestFlat" classname="package/whitespace" time="0.000"></testcase>
|
<testcase name="TestSubTests/TestFlat" classname="package/whitespace" time="0.000">
|
||||||
<testcase name="TestSubTests/TestWithSpace" classname="package/whitespace" time="0.000"></testcase>
|
<system-out><![CDATA[ whitespace_test.go:9: log 1
|
||||||
<testcase name="TestSubTests/TestWithTab" classname="package/whitespace" time="0.000"></testcase>
|
whitespace_test.go:10: log 2
|
||||||
<testcase name="TestSubTests/TestWithNewlinesFlat" classname="package/whitespace" time="0.000"></testcase>
|
printf 1
|
||||||
|
printf 2]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestSubTests/TestWithSpace" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:16: no-space
|
||||||
|
whitespace_test.go:17: one-space
|
||||||
|
whitespace_test.go:18: two-space
|
||||||
|
whitespace_test.go:19: four-space
|
||||||
|
whitespace_test.go:20: eight-space
|
||||||
|
whitespace_test.go:21: no-space
|
||||||
|
no-space
|
||||||
|
one-space
|
||||||
|
two-space
|
||||||
|
four-space
|
||||||
|
eight-space
|
||||||
|
no-space]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestSubTests/TestWithTab" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:31: no-tab
|
||||||
|
whitespace_test.go:32: one-tab
|
||||||
|
whitespace_test.go:33: two-tab
|
||||||
|
no-tab
|
||||||
|
one-tab
|
||||||
|
two-tab]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestSubTests/TestWithNewlinesFlat" classname="package/whitespace" time="0.000">
|
||||||
|
<system-out><![CDATA[ whitespace_test.go:40: no-newline
|
||||||
|
whitespace_test.go:41: one-newline
|
||||||
|
one-newline
|
||||||
|
whitespace_test.go:42: two-newlines
|
||||||
|
two-newlines
|
||||||
|
two-newlines
|
||||||
|
no-newline
|
||||||
|
one-newline
|
||||||
|
one-newline
|
||||||
|
two-newlines
|
||||||
|
two-newlines
|
||||||
|
two-newlines]]></system-out>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
11
testdata/037-legacy-fail.txt
vendored
Normal file
11
testdata/037-legacy-fail.txt
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
=== RUN TestOne
|
||||||
|
--- FAIL: TestOne (0.02 seconds)
|
||||||
|
file_test.go:11: Error message
|
||||||
|
file_test.go:11: Longer
|
||||||
|
error
|
||||||
|
message.
|
||||||
|
=== RUN TestTwo
|
||||||
|
--- PASS: TestTwo (0.13 seconds)
|
||||||
|
FAIL
|
||||||
|
exit status 1
|
||||||
|
FAIL package/name 0.151s
|
17
testdata/037-report.xml
vendored
Normal file
17
testdata/037-report.xml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuites tests="2" failures="1">
|
||||||
|
<testsuite name="package/name" tests="2" failures="1" errors="0" hostname="hostname" time="0.151" timestamp="2022-01-01T00:00:00Z">
|
||||||
|
<properties>
|
||||||
|
<property name="go.version" value="1.0"></property>
|
||||||
|
</properties>
|
||||||
|
<testcase name="TestOne" classname="package/name" time="0.020">
|
||||||
|
<failure message="Failed"></failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestTwo" classname="package/name" time="0.130"></testcase>
|
||||||
|
<system-out><![CDATA[ file_test.go:11: Error message
|
||||||
|
file_test.go:11: Longer
|
||||||
|
error
|
||||||
|
message.
|
||||||
|
exit status 1]]></system-out>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
8
testdata/106-report.xml
vendored
8
testdata/106-report.xml
vendored
@ -4,13 +4,17 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestAck" classname="package/name/main/ack" time="0.000"></testcase>
|
<testcase name="TestAck" classname="package/name/main/ack" time="0.000">
|
||||||
|
<system-out><![CDATA[ ack_test.go:13: ack]]></system-out>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="package/name/main/ok" tests="1" failures="0" errors="0" hostname="hostname" time="0.000" timestamp="2022-01-01T00:00:00Z">
|
<testsuite name="package/name/main/ok" tests="1" failures="0" errors="0" hostname="hostname" time="0.000" timestamp="2022-01-01T00:00:00Z">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestOk" classname="package/name/main/ok" time="0.000"></testcase>
|
<testcase name="TestOk" classname="package/name/main/ok" time="0.000">
|
||||||
|
<system-out><![CDATA[ ok_test.go:13: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="package/name/main/fail" tests="1" failures="0" errors="1" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
|
<testsuite name="package/name/main/fail" tests="1" failures="0" errors="1" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
|
||||||
<properties>
|
<properties>
|
||||||
|
4
testdata/108-report.xml
vendored
4
testdata/108-report.xml
vendored
@ -4,7 +4,9 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestOne" classname="package/name/paniclate" time="0.000"></testcase>
|
<testcase name="TestOne" classname="package/name/paniclate" time="0.000">
|
||||||
|
<system-out><![CDATA[ main_test.go:13: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="Failure" classname="package/name/paniclate" time="0.000">
|
<testcase name="Failure" classname="package/name/paniclate" time="0.000">
|
||||||
<error message="Runtime error"><![CDATA[panic: panic
|
<error message="Runtime error"><![CDATA[panic: panic
|
||||||
|
|
||||||
|
8
testdata/109-report.xml
vendored
8
testdata/109-report.xml
vendored
@ -4,8 +4,12 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="go.version" value="1.0"></property>
|
<property name="go.version" value="1.0"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase name="TestA" classname="package/name/bench" time="0.000"></testcase>
|
<testcase name="TestA" classname="package/name/bench" time="0.000">
|
||||||
<testcase name="TestZ" classname="package/name/bench" time="0.000"></testcase>
|
<system-out><![CDATA[ a_test.go:6: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestZ" classname="package/name/bench" time="0.000">
|
||||||
|
<system-out><![CDATA[ z_test.go:6: ok]]></system-out>
|
||||||
|
</testcase>
|
||||||
<testcase name="BenchmarkTest" classname="package/name/bench" time="0.000000000"></testcase>
|
<testcase name="BenchmarkTest" classname="package/name/bench" time="0.000000000"></testcase>
|
||||||
<testcase name="BenchmarkOtherTest" classname="package/name/bench" time="0.000000000"></testcase>
|
<testcase name="BenchmarkOtherTest" classname="package/name/bench" time="0.000000000"></testcase>
|
||||||
<system-out><![CDATA[goos: linux
|
<system-out><![CDATA[goos: linux
|
||||||
|
Loading…
x
Reference in New Issue
Block a user