...
1# Run chatty tests. Assert on CONT lines.
2! go test chatty_test.go -v
3
4# Sanity check that output occurs.
5stdout -count=2 'this is sub-0'
6stdout -count=2 'this is sub-1'
7stdout -count=2 'this is sub-2'
8stdout -count=1 'error from sub-0'
9stdout -count=1 'error from sub-1'
10stdout -count=1 'error from sub-2'
11
12# Non-parallel tests should not print CONT.
13! stdout CONT
14
15-- chatty_test.go --
16package chatty_test
17
18import (
19 "testing"
20 "fmt"
21)
22
23func TestChatty(t *testing.T) {
24 for i := 0; i < 3; i++ {
25 t.Run(fmt.Sprintf("sub-%d", i), func(t *testing.T) {
26 for j := 0; j < 2; j++ {
27 t.Logf("this is sub-%d", i)
28 }
29 t.Errorf("error from sub-%d", i)
30 })
31 }
32}
View as plain text