-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from dnephin/more-tests
Add a test for junitxml
- Loading branch information
Showing
5 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package junitxml | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"io/ioutil" | ||
"testing" | ||
|
||
"gotest.tools/assert" | ||
"gotest.tools/golden" | ||
"gotest.tools/gotestsum/testjson" | ||
) | ||
|
||
func TestWrite(t *testing.T) { | ||
out := new(bytes.Buffer) | ||
exec := createExecution(t) | ||
|
||
err := Write(out, exec) | ||
assert.NilError(t, err) | ||
golden.Assert(t, out.String(), "junitxml-report.golden") | ||
} | ||
|
||
func createExecution(t *testing.T) *testjson.Execution { | ||
exec, err := testjson.ScanTestOutput(testjson.ScanConfig{ | ||
Stdout: readTestData(t, "out"), | ||
Stderr: readTestData(t, "err"), | ||
Handler: &noopHandler{}, | ||
}) | ||
assert.NilError(t, err) | ||
return exec | ||
} | ||
|
||
func readTestData(t *testing.T, stream string) io.Reader { | ||
raw, err := ioutil.ReadFile("../../testjson/testdata/go-test-json." + stream) | ||
assert.NilError(t, err) | ||
return bytes.NewReader(raw) | ||
} | ||
|
||
type noopHandler struct{} | ||
|
||
func (s *noopHandler) Event(testjson.TestEvent, *testjson.Execution) error { | ||
return nil | ||
} | ||
|
||
func (s *noopHandler) Err(string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuites> | ||
<testsuite tests="0" failures="0" time="0.000s" name="github.com/gotestyourself/gotestyourself/testjson/internal/badmain"> | ||
<properties> | ||
<property name="go.version" value="go1.10.2"></property> | ||
</properties> | ||
<testcase classname="." name="TestMain" time="0.000s"> | ||
<failure message="Failed" type="">sometimes main can exit 2
FAIL	github.com/gotestyourself/gotestyourself/testjson/internal/badmain	0.010s
</failure> | ||
</testcase> | ||
</testsuite> | ||
<testsuite tests="18" failures="0" time="0.020s" name="github.com/gotestyourself/gotestyourself/testjson/internal/good"> | ||
<properties> | ||
<property name="go.version" value="go1.10.2"></property> | ||
</properties> | ||
<testcase classname="good" name="TestSkipped" time="0.000s"> | ||
<skipped message="=== RUN TestSkipped
--- SKIP: TestSkipped (0.00s)
	good_test.go:23: 
"></skipped> | ||
</testcase> | ||
<testcase classname="good" name="TestSkippedWitLog" time="0.000s"> | ||
<skipped message="=== RUN TestSkippedWitLog
--- SKIP: TestSkippedWitLog (0.00s)
	good_test.go:27: the skip message
"></skipped> | ||
</testcase> | ||
<testcase classname="good" name="TestPassed" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestPassedWithLog" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestPassedWithStdout" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestWithStderr" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/a/sub" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/a" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/b/sub" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/b" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/c/sub" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/c" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/d/sub" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess/d" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestNestedSuccess" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestParallelTheThird" time="0.000s"></testcase> | ||
<testcase classname="good" name="TestParallelTheSecond" time="0.010s"></testcase> | ||
<testcase classname="good" name="TestParallelTheFirst" time="0.010s"></testcase> | ||
</testsuite> | ||
<testsuite tests="28" failures="4" time="0.020s" name="github.com/gotestyourself/gotestyourself/testjson/internal/stub"> | ||
<properties> | ||
<property name="go.version" value="go1.10.2"></property> | ||
</properties> | ||
<testcase classname="stub" name="TestFailed" time="0.000s"> | ||
<failure message="Failed" type="">=== RUN TestFailed
--- FAIL: TestFailed (0.00s)
	stub_test.go:34: this failed
</failure> | ||
</testcase> | ||
<testcase classname="stub" name="TestFailedWithStderr" time="0.000s"> | ||
<failure message="Failed" type="">=== RUN TestFailedWithStderr
this is stderr
--- FAIL: TestFailedWithStderr (0.00s)
	stub_test.go:43: also failed
</failure> | ||
</testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/c" time="0.000s"> | ||
<failure message="Failed" type="">=== RUN TestNestedWithFailure/c
 --- FAIL: TestNestedWithFailure/c (0.00s)
 	stub_test.go:65: failed
</failure> | ||
</testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure" time="0.000s"> | ||
<failure message="Failed" type="">=== RUN TestNestedWithFailure
--- FAIL: TestNestedWithFailure (0.00s)
</failure> | ||
</testcase> | ||
<testcase classname="stub" name="TestSkipped" time="0.000s"> | ||
<skipped message="=== RUN TestSkipped
--- SKIP: TestSkipped (0.00s)
	stub_test.go:26: 
"></skipped> | ||
</testcase> | ||
<testcase classname="stub" name="TestSkippedWitLog" time="0.000s"> | ||
<skipped message="=== RUN TestSkippedWitLog
--- SKIP: TestSkippedWitLog (0.00s)
	stub_test.go:30: the skip message
"></skipped> | ||
</testcase> | ||
<testcase classname="stub" name="TestPassed" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestPassedWithLog" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestPassedWithStdout" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestWithStderr" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/a/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/a" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/b/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/b" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/d/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedWithFailure/d" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/a/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/a" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/b/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/b" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/c/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/c" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/d/sub" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess/d" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestNestedSuccess" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestParallelTheThird" time="0.000s"></testcase> | ||
<testcase classname="stub" name="TestParallelTheSecond" time="0.010s"></testcase> | ||
<testcase classname="stub" name="TestParallelTheFirst" time="0.010s"></testcase> | ||
</testsuite> | ||
</testsuites> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters