Skip to content

Commit

Permalink
Expose a skipped test message (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdk authored Feb 26, 2021
1 parent 061ee62 commit 6145f50
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
13 changes: 13 additions & 0 deletions ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 ",
Expand Down
12 changes: 12 additions & 0 deletions testdata/go-junit-report-skipped.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite tests="2" failures="0" time="0.150" name="package/name">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="name" name="TestOne" time="0.020">
<skipped message="file_test.go:11: Skip message"></skipped>
</testcase>
<testcase classname="name" name="TestTwo" time="0.130"></testcase>
</testsuite>
</testsuites>
4 changes: 4 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6145f50

Please sign in to comment.