diff --git a/junit-formatter.go b/junit-formatter.go index b081660..0b58f31 100644 --- a/junit-formatter.go +++ b/junit-formatter.go @@ -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) } diff --git a/parser.go b/parser.go index c5f62eb..0fb6aac 100644 --- a/parser.go +++ b/parser.go @@ -13,6 +13,7 @@ type Result int const ( PASS Result = iota FAIL + SKIP ) type Report struct { @@ -33,7 +34,7 @@ type Test struct { } var ( - regexStatus = regexp.MustCompile(`^--- (PASS|FAIL): (.+) \((\d+\.\d+) seconds\)$`) + regexStatus = regexp.MustCompile(`^--- (PASS|FAIL|SKIP): (.+) \((\d+\.\d+) seconds\)$`) regexResult = regexp.MustCompile(`^(ok|FAIL)\s+(.+)\s(\d+\.\d+)s$`) ) @@ -89,6 +90,8 @@ func Parse(r io.Reader) (*Report, error) { // test status if matches[1] == "PASS" { test.Result = PASS + } else if matches[1] == "SKIP" { + test.Result = SKIP } else { test.Result = FAIL }