add test for flag -no-xml-header

This commit is contained in:
Tachikoma 2014-12-22 21:00:23 +08:00
parent 8cd3db55e5
commit 9745789fe6
3 changed files with 45 additions and 4 deletions

View File

@ -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)
}

View File

@ -0,0 +1,6 @@
=== RUN TestOne
--- PASS: TestOne (0.06s)
=== RUN TestTwo
--- PASS: TestTwo (0.10s)
PASS
ok package/name 0.160s

7
tests/05-report.xml Normal file
View File

@ -0,0 +1,7 @@
<testsuite tests="2" failures="0" time="0.160" name="package/name">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="name" name="TestOne" time="0.060"></testcase>
<testcase classname="name" name="TestTwo" time="0.100"></testcase>
</testsuite>