From d2592490b6d4cb2fcad75df1df1a08b3bab121ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Fri, 1 Apr 2022 20:41:31 +0100 Subject: [PATCH] junit: Include output in JUnit report for successful tests and benchmarks --- junit/junit.go | 4 ++ testdata/001-report.xml | 7 ++- testdata/005-report.xml | 7 ++- testdata/012-report.xml | 8 +++- testdata/019-report.xml | 4 +- testdata/030-report.xml | 50 +++++++++++++++++--- testdata/035-report.xml | 92 ++++++++++++++++++++++++++++++++---- testdata/037-legacy-fail.txt | 11 +++++ testdata/037-report.xml | 17 +++++++ testdata/106-report.xml | 8 +++- testdata/108-report.xml | 4 +- testdata/109-report.xml | 8 +++- 12 files changed, 196 insertions(+), 24 deletions(-) create mode 100644 testdata/037-legacy-fail.txt create mode 100644 testdata/037-report.xml diff --git a/junit/junit.go b/junit/junit.go index aec28b9..3bb0651 100644 --- a/junit/junit.go +++ b/junit/junit.go @@ -178,6 +178,8 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites { Message: "No test result found", Data: formatOutput(test.Output, test.Level), } + } else if len(test.Output) > 0 { + tc.SystemOut = &Output{Data: formatOutput(test.Output, test.Level)} } suite.AddTestcase(tc) @@ -198,6 +200,8 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites { tc.Skipped = &Result{ Message: "Skipped", } + } else if len(bm.Output) > 0 { + tc.SystemOut = &Output{Data: formatOutput(bm.Output, 0)} } suite.AddTestcase(tc) diff --git a/testdata/001-report.xml b/testdata/001-report.xml index 9f6211b..fa64e0e 100644 --- a/testdata/001-report.xml +++ b/testdata/001-report.xml @@ -5,7 +5,12 @@ - + + + diff --git a/testdata/005-report.xml b/testdata/005-report.xml index c147077..4ed233c 100644 --- a/testdata/005-report.xml +++ b/testdata/005-report.xml @@ -4,6 +4,11 @@ - + + + diff --git a/testdata/012-report.xml b/testdata/012-report.xml index 907e171..5d67f11 100644 --- a/testdata/012-report.xml +++ b/testdata/012-report.xml @@ -7,7 +7,9 @@ - + + + @@ -24,7 +26,9 @@ - + + + diff --git a/testdata/019-report.xml b/testdata/019-report.xml index 11db67d..076d782 100644 --- a/testdata/019-report.xml +++ b/testdata/019-report.xml @@ -4,7 +4,9 @@ - + + + diff --git a/testdata/030-report.xml b/testdata/030-report.xml index 20f3375..76b951b 100644 --- a/testdata/030-report.xml +++ b/testdata/030-report.xml @@ -29,9 +29,28 @@ single-line stdout]]> - - - + + + + + + + + + @@ -61,9 +80,28 @@ single-line stdout]]> - - - + + + + + + + + + diff --git a/testdata/035-report.xml b/testdata/035-report.xml index ccabba8..ecd1ced 100644 --- a/testdata/035-report.xml +++ b/testdata/035-report.xml @@ -4,14 +4,90 @@ - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + diff --git a/testdata/037-legacy-fail.txt b/testdata/037-legacy-fail.txt new file mode 100644 index 0000000..905c4d9 --- /dev/null +++ b/testdata/037-legacy-fail.txt @@ -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 diff --git a/testdata/037-report.xml b/testdata/037-report.xml new file mode 100644 index 0000000..743f15d --- /dev/null +++ b/testdata/037-report.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/testdata/106-report.xml b/testdata/106-report.xml index 663c63c..bb39f2c 100644 --- a/testdata/106-report.xml +++ b/testdata/106-report.xml @@ -4,13 +4,17 @@ - + + + - + + + diff --git a/testdata/108-report.xml b/testdata/108-report.xml index c3a4a6b..2de6deb 100644 --- a/testdata/108-report.xml +++ b/testdata/108-report.xml @@ -4,7 +4,9 @@ - + + + - - + + + + + +