Skip to content

Commit 02c7a08

Browse files
committed
Test for repeated output
1 parent 157775e commit 02c7a08

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

testjson/summary_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package testjson
22

33
import (
44
"bytes"
5+
"io"
56
"strings"
67
"testing"
78
"time"
@@ -282,3 +283,21 @@ func TestPrintSummary_WithMissingSkipMessage(t *testing.T) {
282283
//q.Q(exec)
283284
golden.Assert(t, buf.String(), "bug-missing-skip-message-summary.out")
284285
}
286+
287+
func TestPrintSummary_WithRepeatedTestCases(t *testing.T) {
288+
_, reset := patchClock()
289+
defer reset()
290+
291+
in := golden.Get(t, "go-test-json.out")
292+
exec, err := ScanTestOutput(ScanConfig{
293+
Stdout: io.MultiReader(
294+
bytes.NewReader(in),
295+
bytes.NewReader(in),
296+
bytes.NewReader(in)),
297+
})
298+
assert.NilError(t, err)
299+
300+
buf := new(bytes.Buffer)
301+
PrintSummary(buf, exec, SummarizeAll)
302+
golden.Assert(t, buf.String(), "bug-repeated-test-case-output.out")
303+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
=== Skipped
3+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
4+
good_test.go:23:
5+
6+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
7+
good_test.go:27: the skip message
8+
9+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
10+
good_test.go:23:
11+
12+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
13+
good_test.go:27: the skip message
14+
15+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkipped (0.00s)
16+
good_test.go:23:
17+
18+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/good TestSkippedWitLog (0.00s)
19+
good_test.go:27: the skip message
20+
21+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
22+
stub_test.go:26:
23+
24+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
25+
stub_test.go:30: the skip message
26+
27+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
28+
stub_test.go:26:
29+
30+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
31+
stub_test.go:30: the skip message
32+
33+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkipped (0.00s)
34+
stub_test.go:26:
35+
36+
=== SKIP: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestSkippedWitLog (0.00s)
37+
stub_test.go:30: the skip message
38+
39+
40+
=== Failed
41+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/badmain (0.00s)
42+
sometimes main can exit 2
43+
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
44+
sometimes main can exit 2
45+
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
46+
sometimes main can exit 2
47+
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
48+
49+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
50+
stub_test.go:34: this failed
51+
52+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
53+
this is stderr
54+
stub_test.go:43: also failed
55+
56+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
57+
--- FAIL: TestNestedWithFailure/c (0.00s)
58+
stub_test.go:65: failed
59+
60+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)
61+
62+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
63+
stub_test.go:34: this failed
64+
65+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
66+
this is stderr
67+
stub_test.go:43: also failed
68+
69+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
70+
--- FAIL: TestNestedWithFailure/c (0.00s)
71+
stub_test.go:65: failed
72+
73+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)
74+
75+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailed (0.00s)
76+
stub_test.go:34: this failed
77+
78+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestFailedWithStderr (0.00s)
79+
this is stderr
80+
stub_test.go:43: also failed
81+
82+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure/c (0.00s)
83+
--- FAIL: TestNestedWithFailure/c (0.00s)
84+
stub_test.go:65: failed
85+
86+
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (0.00s)
87+
88+
89+
DONE 138 tests, 12 skipped, 13 failures in 0.000s

0 commit comments

Comments
 (0)