diff --git a/ingest_test.go b/ingest_test.go
index 1032e15..8ac0518 100644
--- a/ingest_test.go
+++ b/ingest_test.go
@@ -8,6 +8,8 @@ import (
"fmt"
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/stretchr/testify/require"
)
@@ -59,3 +61,97 @@ func TestIngest(t *testing.T) {
})
}
}
+
+func TestExamplesInTheWild(t *testing.T) {
+ tests := []struct {
+ title string
+ filename string
+ origin string
+ check func(*testing.T, []Suite)
+ }{
+ {
+ title: "catchsoftware example",
+ filename: "testdata/catchsoftware.xml",
+ origin: "https://help.catchsoftware.com/display/ET/JUnit+Format",
+ check: func(t *testing.T, suites []Suite) {
+ assert.Len(t, suites, 2)
+ assert.Len(t, suites[0].Tests, 0)
+ assert.Len(t, suites[1].Tests, 3)
+ assert.EqualError(t, suites[1].Tests[0].Error, "Assertion failed")
+ },
+ },
+ {
+ title: "cubic example",
+ filename: "testdata/cubic.xml",
+ origin: "https://llg.cubic.org/docs/junit/",
+ check: func(t *testing.T, suites []Suite) {
+ assert.Len(t, suites, 1)
+ assert.Len(t, suites[0].Tests, 1)
+ assert.Equal(t, "STDOUT text", suites[0].SystemOut)
+ assert.Equal(t, "STDERR text", suites[0].SystemErr)
+ assert.Equal(t, "STDOUT text", suites[0].Tests[0].SystemOut)
+ assert.Equal(t, "STDERR text", suites[0].Tests[0].SystemErr)
+ },
+ },
+ {
+ title: "go-junit-report example",
+ filename: "testdata/go-junit-report.xml",
+ origin: "https://github.com/jstemmer/go-junit-report/blob/master/testdata/06-report.xml",
+ check: func(t *testing.T, suites []Suite) {
+ assert.Len(t, suites, 2)
+ assert.Len(t, suites[0].Tests, 2)
+ assert.Len(t, suites[1].Tests, 2)
+ assert.Equal(t, "1.0", suites[0].Properties["go.version"])
+ assert.Equal(t, "1.0", suites[1].Properties["go.version"])
+ assert.EqualError(t, suites[1].Tests[0].Error, "file_test.go:11: Error message\nfile_test.go:11: Longer\n\terror\n\tmessage.")
+ },
+ },
+ {
+ title: "ibm example",
+ filename: "testdata/ibm.xml",
+ origin: "https://www.ibm.com/support/knowledgecenter/en/SSQ2R2_14.2.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html",
+ check: func(t *testing.T, suites []Suite) {
+ },
+ },
+ {
+ title: "jenkinsci example",
+ filename: "testdata/jenkinsci.xml",
+ origin: "https://github.com/jenkinsci/junit-plugin/blob/master/src/test/resources/hudson/tasks/junit/junit-report-1463.xml",
+ check: func(t *testing.T, suites []Suite) {
+ },
+ },
+ {
+ title: "nose2 example",
+ filename: "testdata/nose2.xml",
+ origin: "https://nose2.readthedocs.io/en/latest/plugins/junitxml.html",
+ check: func(t *testing.T, suites []Suite) {
+ },
+ },
+ {
+ title: "python junit-xml example",
+ filename: "testdata/python-junit-xml.xml",
+ origin: "https://pypi.org/project/junit-xml/",
+ check: func(t *testing.T, suites []Suite) {
+ },
+ },
+ {
+ title: "surefire example",
+ filename: "testdata/surefire.xml",
+ origin: "https://gist.github.com/rwbergstrom/6f0193b1a12dca9d358e6043ee6abba4",
+ check: func(t *testing.T, suites []Suite) {
+ assert.Equal(t, "Hello, World\n", suites[0].Tests[0].SystemOut)
+ assert.Equal(t, "I'm an error!\n", suites[0].Tests[0].SystemErr)
+ },
+ },
+ }
+
+ for index, test := range tests {
+ name := fmt.Sprintf("#%d - %s", index+1, test.title)
+
+ t.Run(name, func(t *testing.T) {
+ suites, err := IngestFile(test.filename)
+ require.NoError(t, err)
+ test.check(t, suites)
+ })
+ }
+}
diff --git a/testdata/catchsoftware.xml b/testdata/catchsoftware.xml
new file mode 100644
index 0000000..ee8ef3e
--- /dev/null
+++ b/testdata/catchsoftware.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+ Assertion failed
+
+
+
+
+
+
+
diff --git a/testdata/cubic.xml b/testdata/cubic.xml
new file mode 100644
index 0000000..eb695db
--- /dev/null
+++ b/testdata/cubic.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ STDOUT text
+
+
+ STDERR text
+
+
+
+ STDOUT text
+
+ STDERR text
+
+
diff --git a/testdata/go-junit-report.xml b/testdata/go-junit-report.xml
new file mode 100644
index 0000000..8b2ab23
--- /dev/null
+++ b/testdata/go-junit-report.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file_test.go:11: Error message
file_test.go:11: Longer
error
message.
+
+
+
+
diff --git a/testdata/ibm.xml b/testdata/ibm.xml
new file mode 100644
index 0000000..cea95e5
--- /dev/null
+++ b/testdata/ibm.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+WARNING: Use a program name that matches the source file name
+Category: COBOL Code Review – Naming Conventions
+File: /project/PROGRAM.cbl
+Line: 2
+
+
+
+
diff --git a/testdata/jenkinsci.xml b/testdata/jenkinsci.xml
new file mode 100644
index 0000000..47035b9
--- /dev/null
+++ b/testdata/jenkinsci.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testdata/nose2.xml b/testdata/nose2.xml
new file mode 100644
index 0000000..0672ab5
--- /dev/null
+++ b/testdata/nose2.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/plugins/loader/parameters.py", line 162, in func
+ return obj(*argSet)
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 64, in test_params_func
+ assert a == 1
+AssertionError
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/plugins/loader/parameters.py", line 162, in func
+ return obj(*argSet)
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 69, in test_params_func_multi_arg
+ assert a == b
+AssertionError
+
+
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 17, in test_failed
+ assert False, "I failed"
+AssertionError: I failed
+
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/plugins/loader/parameters.py", line 144, in _method
+ return method(self, *argSet)
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 29, in test_params_method
+ self.assertEqual(a, 1)
+AssertionError: 2 != 1
+
+
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 13, in test_typeerr
+ raise TypeError("oops")
+TypeError: oops
+
+
+
+
+ Traceback (most recent call last):
+ File "nose2/plugins/loader/generators.py", line 145, in method
+ return func(*args)
+ File "nose2/tests/functional/support/scenario/tests_in_package/pkg1/test/test_things.py", line 24, in check
+ assert x == 1
+AssertionError
+
+
+
diff --git a/testdata/python-junit-xml.xml b/testdata/python-junit-xml.xml
new file mode 100644
index 0000000..3957224
--- /dev/null
+++ b/testdata/python-junit-xml.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ I am stdout!
+
+
+ I am stderr!
+
+
+
+
diff --git a/testdata/surefire.xml b/testdata/surefire.xml
new file mode 100644
index 0000000..c41dd45
--- /dev/null
+++ b/testdata/surefire.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ java.lang.AssertionError
+ at com.example.FooTest.testStdoutStderr(FooTest.java:13)
+
+
+
+
+