gotest.tools/gotestsum@v1.11.0/testjson/internal/parallelfails/fails_test.go (about) 1 // +build stubpkg 2 3 package fails 4 5 import ( 6 "fmt" 7 "os" 8 "testing" 9 "time" 10 ) 11 12 func TestPassed(t *testing.T) {} 13 14 func TestPassedWithLog(t *testing.T) { 15 t.Log("this is a log") 16 } 17 18 func TestPassedWithStdout(t *testing.T) { 19 fmt.Println("this is a Print") 20 } 21 22 func TestWithStderr(t *testing.T) { 23 fmt.Fprintln(os.Stderr, "this is stderr") 24 } 25 26 func TestParallelTheFirst(t *testing.T) { 27 t.Parallel() 28 time.Sleep(10 * time.Millisecond) 29 t.Fatal("failed the first") 30 } 31 32 func TestParallelTheSecond(t *testing.T) { 33 t.Parallel() 34 time.Sleep(6 * time.Millisecond) 35 t.Fatal("failed the second") 36 } 37 38 func TestParallelTheThird(t *testing.T) { 39 t.Parallel() 40 time.Sleep(2 * time.Millisecond) 41 t.Fatal("failed the third") 42 43 } 44 45 func TestNestedParallelFailures(t *testing.T) { 46 for _, name := range []string{"a", "b", "c", "d"} { 47 name := name 48 t.Run(name, func(t *testing.T) { 49 t.Parallel() 50 t.Fatal("failed sub " + name) 51 }) 52 } 53 }