mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-06 21:48:08 -05:00
identify skipped tests properly with a message
This commit is contained in:
parent
9922c23bd3
commit
5c1ba2f305
@ -20,11 +20,16 @@ type JUnitTestSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type JUnitTestCase struct {
|
type JUnitTestCase struct {
|
||||||
XMLName xml.Name `xml:"testcase"`
|
XMLName xml.Name `xml:"testcase"`
|
||||||
Classname string `xml:"classname,attr"`
|
Classname string `xml:"classname,attr"`
|
||||||
Name string `xml:"name,attr"`
|
Name string `xml:"name,attr"`
|
||||||
Time string `xml:"time,attr"`
|
Time string `xml:"time,attr"`
|
||||||
Failure *JUnitFailure `xml:"failure,omitempty"`
|
SkipMessage *JUnitSkipMessage `xml:"skipped,omitempty"`
|
||||||
|
Failure *JUnitFailure `xml:"failure,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JUnitSkipMessage struct {
|
||||||
|
Message string `xml:"message,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JUnitProperty struct {
|
type JUnitProperty struct {
|
||||||
@ -88,6 +93,10 @@ func JUnitReportXML(report *Report, w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if test.Result == SKIP {
|
||||||
|
testCase.SkipMessage = &JUnitSkipMessage{strings.Join(test.Output, "\n")}
|
||||||
|
}
|
||||||
|
|
||||||
ts.TestCases = append(ts.TestCases, testCase)
|
ts.TestCases = append(ts.TestCases, testCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ type Result int
|
|||||||
const (
|
const (
|
||||||
PASS Result = iota
|
PASS Result = iota
|
||||||
FAIL
|
FAIL
|
||||||
|
SKIP
|
||||||
)
|
)
|
||||||
|
|
||||||
type Report struct {
|
type Report struct {
|
||||||
@ -87,8 +88,10 @@ func Parse(r io.Reader) (*Report, error) {
|
|||||||
} else if test != nil {
|
} else if test != nil {
|
||||||
if matches := regexStatus.FindStringSubmatch(line); len(matches) == 4 {
|
if matches := regexStatus.FindStringSubmatch(line); len(matches) == 4 {
|
||||||
// test status
|
// test status
|
||||||
if matches[1] == "PASS" || matches[1] == "SKIP" {
|
if matches[1] == "PASS" {
|
||||||
test.Result = PASS
|
test.Result = PASS
|
||||||
|
} else if matches[1] == "SKIP" {
|
||||||
|
test.Result = SKIP
|
||||||
} else {
|
} else {
|
||||||
test.Result = FAIL
|
test.Result = FAIL
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user