From 9745789fe6cadbed882d21b89542437cee64976c Mon Sep 17 00:00:00 2001 From: Tachikoma Date: Mon, 22 Dec 2014 21:00:23 +0800 Subject: [PATCH] add test for flag -no-xml-header --- go-junit-report_test.go | 36 ++++++++++++++++++++++++++++++++---- tests/05-no_xml_header.txt | 6 ++++++ tests/05-report.xml | 7 +++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 tests/05-no_xml_header.txt create mode 100644 tests/05-report.xml diff --git a/go-junit-report_test.go b/go-junit-report_test.go index 853d614..c268f0a 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -11,9 +11,10 @@ import ( ) type TestCase struct { - name string - reportName string - report *Report + name string + reportName string + report *Report + noXmlHeader bool } var testCases []TestCase = []TestCase{ @@ -128,6 +129,33 @@ var testCases []TestCase = []TestCase{ }, }, }, + { + name: "05-no_xml_header.txt", + reportName: "05-report.xml", + report: &Report{ + Packages: []Package{ + { + Name: "package/name", + Time: 160, + Tests: []Test{ + { + Name: "TestOne", + Time: 60, + Result: PASS, + Output: []string{}, + }, + { + Name: "TestTwo", + Time: 100, + Result: PASS, + Output: []string{}, + }, + }, + }, + }, + }, + noXmlHeader: true, + }, } func TestParser(t *testing.T) { @@ -200,7 +228,7 @@ func TestJUnitFormatter(t *testing.T) { var junitReport bytes.Buffer - if err = JUnitReportXML(testCase.report, &junitReport); err != nil { + if err = JUnitReportXML(testCase.report, testCase.noXmlHeader, &junitReport); err != nil { t.Fatal(err) } diff --git a/tests/05-no_xml_header.txt b/tests/05-no_xml_header.txt new file mode 100644 index 0000000..13fe892 --- /dev/null +++ b/tests/05-no_xml_header.txt @@ -0,0 +1,6 @@ +=== RUN TestOne +--- PASS: TestOne (0.06s) +=== RUN TestTwo +--- PASS: TestTwo (0.10s) +PASS +ok package/name 0.160s \ No newline at end of file diff --git a/tests/05-report.xml b/tests/05-report.xml new file mode 100644 index 0000000..5a372aa --- /dev/null +++ b/tests/05-report.xml @@ -0,0 +1,7 @@ + + + + + + +