Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c2c5ed

Browse files
committed
assert,require: enable parallel testing on (almost) all top tests
Enable parallel testing for almost all tests in packages 'assert' and 'require' by calling t.Parallel() as the first line of the test. A few tests are incompatible and will be fixed separately. They are marked with a FIXME. Incompatible tests: TestFileExists, TestNoFileExists, TestDirExists, TestNoDirExists. Before: $ go test -count=10 ./assert ./require ok github.com/stretchr/testify/assert 7.575s ok github.com/stretchr/testify/require 1.501s After: $ go test -count=10 ./assert ./require ok github.com/stretchr/testify/assert 1.703s ok github.com/stretchr/testify/require 1.245s
1 parent 9fc264e commit 1c2c5ed

7 files changed

+525
-0
lines changed

assert/assertion_compare_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
)
1111

1212
func TestCompare(t *testing.T) {
13+
t.Parallel()
14+
1315
type customString string
1416
type customInt int
1517
type customInt8 int8
@@ -127,6 +129,8 @@ func callerName(skip int) string {
127129
}
128130

129131
func TestGreater(t *testing.T) {
132+
t.Parallel()
133+
130134
mockT := new(testing.T)
131135

132136
if !Greater(mockT, 2, 1) {
@@ -171,6 +175,8 @@ func TestGreater(t *testing.T) {
171175
}
172176

173177
func TestGreaterOrEqual(t *testing.T) {
178+
t.Parallel()
179+
174180
mockT := new(testing.T)
175181

176182
if !GreaterOrEqual(mockT, 2, 1) {
@@ -215,6 +221,8 @@ func TestGreaterOrEqual(t *testing.T) {
215221
}
216222

217223
func TestLess(t *testing.T) {
224+
t.Parallel()
225+
218226
mockT := new(testing.T)
219227

220228
if !Less(mockT, 1, 2) {
@@ -259,6 +267,8 @@ func TestLess(t *testing.T) {
259267
}
260268

261269
func TestLessOrEqual(t *testing.T) {
270+
t.Parallel()
271+
262272
mockT := new(testing.T)
263273

264274
if !LessOrEqual(mockT, 1, 2) {
@@ -303,6 +313,8 @@ func TestLessOrEqual(t *testing.T) {
303313
}
304314

305315
func TestPositive(t *testing.T) {
316+
t.Parallel()
317+
306318
mockT := new(testing.T)
307319

308320
if !Positive(mockT, 1) {
@@ -342,6 +354,8 @@ func TestPositive(t *testing.T) {
342354
}
343355

344356
func TestNegative(t *testing.T) {
357+
t.Parallel()
358+
345359
mockT := new(testing.T)
346360

347361
if !Negative(mockT, -1) {
@@ -381,6 +395,8 @@ func TestNegative(t *testing.T) {
381395
}
382396

383397
func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) {
398+
t.Parallel()
399+
384400
mockT := new(testing.T)
385401

386402
for _, currCase := range []struct {
@@ -399,6 +415,8 @@ func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) {
399415
}
400416

401417
func Test_compareTwoValuesNotComparableValues(t *testing.T) {
418+
t.Parallel()
419+
402420
mockT := new(testing.T)
403421

404422
type CompareStruct struct {
@@ -418,6 +436,8 @@ func Test_compareTwoValuesNotComparableValues(t *testing.T) {
418436
}
419437

420438
func Test_compareTwoValuesCorrectCompareResult(t *testing.T) {
439+
t.Parallel()
440+
421441
mockT := new(testing.T)
422442

423443
for _, currCase := range []struct {
@@ -438,6 +458,8 @@ func Test_compareTwoValuesCorrectCompareResult(t *testing.T) {
438458
}
439459

440460
func Test_containsValue(t *testing.T) {
461+
t.Parallel()
462+
441463
for _, currCase := range []struct {
442464
values []compareResult
443465
value compareResult

assert/assertion_order_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
)
77

88
func TestIsIncreasing(t *testing.T) {
9+
t.Parallel()
10+
911
mockT := new(testing.T)
1012

1113
if !IsIncreasing(mockT, []int{1, 2}) {
@@ -51,6 +53,8 @@ func TestIsIncreasing(t *testing.T) {
5153
}
5254

5355
func TestIsNonIncreasing(t *testing.T) {
56+
t.Parallel()
57+
5458
mockT := new(testing.T)
5559

5660
if !IsNonIncreasing(mockT, []int{2, 1}) {
@@ -96,6 +100,8 @@ func TestIsNonIncreasing(t *testing.T) {
96100
}
97101

98102
func TestIsDecreasing(t *testing.T) {
103+
t.Parallel()
104+
99105
mockT := new(testing.T)
100106

101107
if !IsDecreasing(mockT, []int{2, 1}) {
@@ -141,6 +147,8 @@ func TestIsDecreasing(t *testing.T) {
141147
}
142148

143149
func TestIsNonDecreasing(t *testing.T) {
150+
t.Parallel()
151+
144152
mockT := new(testing.T)
145153

146154
if !IsNonDecreasing(mockT, []int{1, 2}) {
@@ -186,6 +194,8 @@ func TestIsNonDecreasing(t *testing.T) {
186194
}
187195

188196
func TestOrderingMsgAndArgsForwarding(t *testing.T) {
197+
t.Parallel()
198+
189199
msgAndArgs := []interface{}{"format %s %x", "this", 0xc001}
190200
expectedOutput := "format this c001\n"
191201
collection := []int{1, 2, 1}

0 commit comments

Comments
 (0)