Skip to content

Commit

Permalink
Test for repeated output
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 6, 2020
1 parent 157775e commit 02c7a08
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
19 changes: 19 additions & 0 deletions testjson/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testjson

import (
"bytes"
"io"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -282,3 +283,21 @@ func TestPrintSummary_WithMissingSkipMessage(t *testing.T) {
//q.Q(exec)
golden.Assert(t, buf.String(), "bug-missing-skip-message-summary.out")
}

func TestPrintSummary_WithRepeatedTestCases(t *testing.T) {
_, reset := patchClock()
defer reset()

in := golden.Get(t, "go-test-json.out")
exec, err := ScanTestOutput(ScanConfig{
Stdout: io.MultiReader(
bytes.NewReader(in),
bytes.NewReader(in),
bytes.NewReader(in)),
})
assert.NilError(t, err)

buf := new(bytes.Buffer)
PrintSummary(buf, exec, SummarizeAll)
golden.Assert(t, buf.String(), "bug-repeated-test-case-output.out")
}
89 changes: 89 additions & 0 deletions testjson/testdata/bug-repeated-test-case-output.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

=== Skipped
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
good_test.go:23:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
good_test.go:27: the skip message

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
good_test.go:23:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
good_test.go:27: the skip message

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
good_test.go:23:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
good_test.go:27: the skip message

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
stub_test.go:26:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
stub_test.go:30: the skip message

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
stub_test.go:26:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
stub_test.go:30: the skip message

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
stub_test.go:26:

=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
stub_test.go:30: the skip message


=== Failed
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/badmain (0.00s)
sometimes main can exit 2
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
sometimes main can exit 2
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
sometimes main can exit 2
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
stub_test.go:34: this failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
this is stderr
stub_test.go:43: also failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
--- FAIL: TestNestedWithFailure/c (0.00s)
stub_test.go:65: failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
stub_test.go:34: this failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
this is stderr
stub_test.go:43: also failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
--- FAIL: TestNestedWithFailure/c (0.00s)
stub_test.go:65: failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
stub_test.go:34: this failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
this is stderr
stub_test.go:43: also failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
--- FAIL: TestNestedWithFailure/c (0.00s)
stub_test.go:65: failed

=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)


DONE 138 tests, 12 skipped, 13 failures in 0.000s

0 comments on commit 02c7a08

Please sign in to comment.