mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-06 14:02:52 -05:00
Parse test failure messages
This commit is contained in:
@ -20,11 +20,11 @@ type JUnitTestSuite struct {
|
||||
}
|
||||
|
||||
type JUnitTestCase struct {
|
||||
XMLName xml.Name `xml:"testcase"`
|
||||
Classname string `xml:"classname,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Time string `xml:"time,attr"`
|
||||
Failure string `xml:"failure,omitempty"`
|
||||
XMLName xml.Name `xml:"testcase"`
|
||||
Classname string `xml:"classname,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Time string `xml:"time,attr"`
|
||||
Failure *JUnitFailure `xml:"failure,omitempty"`
|
||||
}
|
||||
|
||||
type JUnitProperty struct {
|
||||
@ -32,6 +32,12 @@ type JUnitProperty struct {
|
||||
Value string `xml:"value,attr"`
|
||||
}
|
||||
|
||||
type JUnitFailure struct {
|
||||
Message string `xml:"message,attr"`
|
||||
Type string `xml:"type,attr"`
|
||||
Contents string `xml:",chardata"`
|
||||
}
|
||||
|
||||
func NewJUnitProperty(name, value string) JUnitProperty {
|
||||
return JUnitProperty{
|
||||
Name: name,
|
||||
@ -69,14 +75,17 @@ func JUnitReportXML(report *Report, w io.Writer) error {
|
||||
Classname: classname,
|
||||
Name: test.Name,
|
||||
Time: formatTime(test.Time),
|
||||
Failure: "",
|
||||
Failure: nil,
|
||||
}
|
||||
|
||||
if test.Result == FAIL {
|
||||
ts.Failures += 1
|
||||
|
||||
// TODO: set error message
|
||||
testCase.Failure = "Failed"
|
||||
testCase.Failure = &JUnitFailure{
|
||||
Message: "Failed",
|
||||
Type: "",
|
||||
Contents: strings.Join(test.Output, "\n"),
|
||||
}
|
||||
}
|
||||
|
||||
ts.TestCases = append(ts.TestCases, testCase)
|
||||
|
Reference in New Issue
Block a user