diff --git a/ingest.go b/ingest.go index 4472ebc..0d21a52 100644 --- a/ingest.go +++ b/ingest.go @@ -79,12 +79,15 @@ func ingestTestcase(root xmlNode) Test { switch node.XMLName.Local { case "skipped": test.Status = StatusSkipped + test.Message = node.Attr("message") case "failure": - test.Error = ingestError(node) test.Status = StatusFailed - case "error": + test.Message = node.Attr("message") test.Error = ingestError(node) + case "error": test.Status = StatusError + test.Message = node.Attr("message") + test.Error = ingestError(node) case "system-out": test.SystemOut = string(node.Content) case "system-err": diff --git a/ingest_test.go b/ingest_test.go index 457019b..4333045 100644 --- a/ingest_test.go +++ b/ingest_test.go @@ -57,6 +57,18 @@ func TestExamplesInTheWild(t *testing.T) { assert.EqualError(t, suites[1].Tests[0].Error, "file_test.go:11: Error message\nfile_test.go:11: Longer\n\terror\n\tmessage.") }, }, + { + title: "go-junit-report skipped example", + filename: "testdata/go-junit-report-skipped.xml", + origin: "https://github.com/jstemmer/go-junit-report/blob/master/testdata/03-report.xml", + check: func(t *testing.T, suites []Suite) { + assert.Len(t, suites, 1) + assert.Len(t, suites[0].Tests, 2) + assert.Equal(t, "package/name", suites[0].Name) + assert.Equal(t, "TestOne", suites[0].Tests[0].Name) + assert.Equal(t, "file_test.go:11: Skip message", suites[0].Tests[0].Message) + }, + }, { title: "ibm example", filename: "testdata/ibm.xml", @@ -143,6 +155,7 @@ func TestExamplesInTheWild(t *testing.T) { Classname: "TestClassSample", Duration: 342 * time.Millisecond, Status: StatusFailed, + Message: "XCTAssertTrue failed", Error: Error{ Message: "XCTAssertTrue failed", Body: "\n ", diff --git a/testdata/go-junit-report-skipped.xml b/testdata/go-junit-report-skipped.xml new file mode 100644 index 0000000..e67e5ef --- /dev/null +++ b/testdata/go-junit-report-skipped.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/types.go b/types.go index d01c6ba..35d1299 100644 --- a/types.go +++ b/types.go @@ -136,6 +136,10 @@ type Test struct { // failure, & error. Status Status `json:"status" yaml:"status"` + // Message is an textual description optionally included with a skipped, + // failure, or error test case. + Message string `json:"message" yaml:"message"` + // Error is a record of the failure or error of a test, if applicable. // // The following relations should hold true.