mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-05 05:00:15 -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 {
|
||||
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"`
|
||||
XMLName xml.Name `xml:"testcase"`
|
||||
Classname string `xml:"classname,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Time string `xml:"time,attr"`
|
||||
SkipMessage *JUnitSkipMessage `xml:"skipped,omitempty"`
|
||||
Failure *JUnitFailure `xml:"failure,omitempty"`
|
||||
}
|
||||
|
||||
type JUnitSkipMessage struct {
|
||||
Message string `xml:"message,attr"`
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ type Result int
|
||||
const (
|
||||
PASS Result = iota
|
||||
FAIL
|
||||
SKIP
|
||||
)
|
||||
|
||||
type Report struct {
|
||||
@ -87,8 +88,10 @@ func Parse(r io.Reader) (*Report, error) {
|
||||
} else if test != nil {
|
||||
if matches := regexStatus.FindStringSubmatch(line); len(matches) == 4 {
|
||||
// test status
|
||||
if matches[1] == "PASS" || matches[1] == "SKIP" {
|
||||
if matches[1] == "PASS" {
|
||||
test.Result = PASS
|
||||
} else if matches[1] == "SKIP" {
|
||||
test.Result = SKIP
|
||||
} else {
|
||||
test.Result = FAIL
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user