From fc2896020a1b7b3283fdb5ce12a7a73d33a1a244 Mon Sep 17 00:00:00 2001 From: Nick Palmer Date: Tue, 13 Jan 2015 18:45:30 -0800 Subject: [PATCH] Add a test case which has more than one suite in it. --- go-junit-report_test.go | 52 +++++++++++++++++++++++++++++++++++++++++ tests/06-mixed.txt | 17 ++++++++++++++ tests/06-report.xml | 18 ++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tests/06-mixed.txt create mode 100644 tests/06-report.xml diff --git a/go-junit-report_test.go b/go-junit-report_test.go index 1d5e349..5bcf2b4 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -156,10 +156,62 @@ var testCases []TestCase = []TestCase{ }, noXmlHeader: true, }, + { + name: "06-mixed.txt", + reportName: "06-report.xml", + report: &Report{ + Packages: []Package{ + { + Name: "package/name1", + Time: 160, + Tests: []Test{ + { + Name: "TestOne", + Time: 60, + Result: PASS, + Output: []string{}, + }, + { + Name: "TestTwo", + Time: 100, + Result: PASS, + Output: []string{}, + }, + }, + }, + { + Name: "package/name2", + Time: 151, + Tests: []Test{ + { + Name: "TestOne", + Time: 20, + Result: FAIL, + Output: []string{ + "file_test.go:11: Error message", + "file_test.go:11: Longer", + "\terror", + "\tmessage.", + }, + }, + { + Name: "TestTwo", + Time: 130, + Result: PASS, + Output: []string{}, + }, + }, + }, + }, + }, + noXmlHeader: true, + }, } func TestParser(t *testing.T) { for _, testCase := range testCases { + t.Logf("Running: %s", testCase.name) + file, err := os.Open("tests/" + testCase.name) if err != nil { t.Fatal(err) diff --git a/tests/06-mixed.txt b/tests/06-mixed.txt new file mode 100644 index 0000000..a2a744d --- /dev/null +++ b/tests/06-mixed.txt @@ -0,0 +1,17 @@ +=== RUN TestOne +--- PASS: TestOne (0.06 seconds) +=== RUN TestTwo +--- PASS: TestTwo (0.10 seconds) +PASS +ok package/name1 0.160s +=== 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/name2 0.151s diff --git a/tests/06-report.xml b/tests/06-report.xml new file mode 100644 index 0000000..bb872f2 --- /dev/null +++ b/tests/06-report.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + file_test.go:11: Error message file_test.go:11: Longer error message. + + + +