Skip to content

Commit 6145f50

Browse files
authored
Expose a skipped test message (#41)
1 parent 061ee62 commit 6145f50

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

ingest.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,15 @@ func ingestTestcase(root xmlNode) Test {
7979
switch node.XMLName.Local {
8080
case "skipped":
8181
test.Status = StatusSkipped
82+
test.Message = node.Attr("message")
8283
case "failure":
83-
test.Error = ingestError(node)
8484
test.Status = StatusFailed
85-
case "error":
85+
test.Message = node.Attr("message")
8686
test.Error = ingestError(node)
87+
case "error":
8788
test.Status = StatusError
89+
test.Message = node.Attr("message")
90+
test.Error = ingestError(node)
8891
case "system-out":
8992
test.SystemOut = string(node.Content)
9093
case "system-err":

ingest_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ func TestExamplesInTheWild(t *testing.T) {
5757
assert.EqualError(t, suites[1].Tests[0].Error, "file_test.go:11: Error message\nfile_test.go:11: Longer\n\terror\n\tmessage.")
5858
},
5959
},
60+
{
61+
title: "go-junit-report skipped example",
62+
filename: "testdata/go-junit-report-skipped.xml",
63+
origin: "https://github.com/jstemmer/go-junit-report/blob/master/testdata/03-report.xml",
64+
check: func(t *testing.T, suites []Suite) {
65+
assert.Len(t, suites, 1)
66+
assert.Len(t, suites[0].Tests, 2)
67+
assert.Equal(t, "package/name", suites[0].Name)
68+
assert.Equal(t, "TestOne", suites[0].Tests[0].Name)
69+
assert.Equal(t, "file_test.go:11: Skip message", suites[0].Tests[0].Message)
70+
},
71+
},
6072
{
6173
title: "ibm example",
6274
filename: "testdata/ibm.xml",
@@ -143,6 +155,7 @@ func TestExamplesInTheWild(t *testing.T) {
143155
Classname: "TestClassSample",
144156
Duration: 342 * time.Millisecond,
145157
Status: StatusFailed,
158+
Message: "XCTAssertTrue failed",
146159
Error: Error{
147160
Message: "XCTAssertTrue failed",
148161
Body: "\n ",

testdata/go-junit-report-skipped.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite tests="2" failures="0" time="0.150" name="package/name">
4+
<properties>
5+
<property name="go.version" value="1.0"></property>
6+
</properties>
7+
<testcase classname="name" name="TestOne" time="0.020">
8+
<skipped message="file_test.go:11: Skip message"></skipped>
9+
</testcase>
10+
<testcase classname="name" name="TestTwo" time="0.130"></testcase>
11+
</testsuite>
12+
</testsuites>

types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ type Test struct {
136136
// failure, & error.
137137
Status Status `json:"status" yaml:"status"`
138138

139+
// Message is an textual description optionally included with a skipped,
140+
// failure, or error test case.
141+
Message string `json:"message" yaml:"message"`
142+
139143
// Error is a record of the failure or error of a test, if applicable.
140144
//
141145
// The following relations should hold true.

0 commit comments

Comments
 (0)