...
1[short] skip
2
3# test fail fast
4! go test ./failfast_test.go -run='TestFailingA' -failfast=true
5stdout -count=1 'FAIL - '
6! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=true
7stdout -count=1 'FAIL - '
8! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=false
9stdout -count=2 'FAIL - '
10
11# mix with non-failing tests
12! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=true
13stdout -count=1 'FAIL - '
14! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=false
15stdout -count=2 'FAIL - '
16
17# mix with parallel tests
18! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=true
19stdout -count=2 'FAIL - '
20! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=false
21stdout -count=2 'FAIL - '
22! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=true
23stdout -count=3 'FAIL - '
24! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=false
25stdout -count=3 'FAIL - '
26
27# mix with parallel sub-tests
28! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=true
29stdout -count=3 'FAIL - '
30! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=false
31stdout -count=5 'FAIL - '
32! go test ./failfast_test.go -run='TestParallelFailingSubtestsA' -failfast=true
33stdout -count=1 'FAIL - '
34
35# only parallels
36! go test ./failfast_test.go -run='TestParallelFailing[AB]' -failfast=false
37stdout -count=2 'FAIL - '
38
39# non-parallel subtests
40! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=true
41stdout -count=1 'FAIL - '
42! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=false
43stdout -count=2 'FAIL - '
44
45# fatal test
46! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=true
47stdout -count=1 'FAIL - '
48! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=false
49stdout -count=2 'FAIL - '
50
51-- failfast_test.go --
52// Copyright 2017 The Go Authors. All rights reserved.
53// Use of this source code is governed by a BSD-style
54// license that can be found in the LICENSE file.
55
56package failfast
57
58import "testing"
59
60func TestA(t *testing.T) {
61 // Edge-case testing, mixing unparallel tests too
62 t.Logf("LOG: %s", t.Name())
63}
64
65func TestFailingA(t *testing.T) {
66 t.Errorf("FAIL - %s", t.Name())
67}
68
69func TestB(t *testing.T) {
70 // Edge-case testing, mixing unparallel tests too
71 t.Logf("LOG: %s", t.Name())
72}
73
74func TestParallelFailingA(t *testing.T) {
75 t.Parallel()
76 t.Errorf("FAIL - %s", t.Name())
77}
78
79func TestParallelFailingB(t *testing.T) {
80 t.Parallel()
81 t.Errorf("FAIL - %s", t.Name())
82}
83
84func TestParallelFailingSubtestsA(t *testing.T) {
85 t.Parallel()
86 t.Run("TestFailingSubtestsA1", func(t *testing.T) {
87 t.Errorf("FAIL - %s", t.Name())
88 })
89 t.Run("TestFailingSubtestsA2", func(t *testing.T) {
90 t.Errorf("FAIL - %s", t.Name())
91 })
92}
93
94func TestFailingSubtestsA(t *testing.T) {
95 t.Run("TestFailingSubtestsA1", func(t *testing.T) {
96 t.Errorf("FAIL - %s", t.Name())
97 })
98 t.Run("TestFailingSubtestsA2", func(t *testing.T) {
99 t.Errorf("FAIL - %s", t.Name())
100 })
101}
102
103func TestFailingB(t *testing.T) {
104 t.Errorf("FAIL - %s", t.Name())
105}
106
107func TestFatalC(t *testing.T) {
108 t.Fatalf("FAIL - %s", t.Name())
109}
110
111func TestFatalD(t *testing.T) {
112 t.Fatalf("FAIL - %s", t.Name())
113}
View as plain text