Skip to content

Commit

Permalink
add test cases for named function
Browse files Browse the repository at this point in the history
  • Loading branch information
moricho committed Sep 4, 2020
1 parent 72efe22 commit 2a45336
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions testdata/src/sample/namedfunc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package sample

import "testing"

func testFn1(t *testing.T) {
t.Parallel()
call("Named1_Sub")
}

func testFn2(t *testing.T) {
call("Named2_Sub")
}

func testFn3(t *testing.T) {
t.Parallel()
call("Named3_Sub")
}

func Test_Named1(t *testing.T) { // want "Test_Named1 should call t.Parallel on the top level"
teardown := setup("Test_Named1")
t.Cleanup(teardown)

fn := testFn1

t.Run("Named1_Sub1", fn)

t.Run("Named1_Sub2", fn)
}

func Test_Named2(t *testing.T) { // want "Test_Named2's sub tests should call t.Parallel"
teardown := setup("Test_Named1")
t.Cleanup(teardown)
t.Parallel()

fn := testFn2

t.Run("Named2_Sub1", fn)

t.Run("Named2_Sub2", fn)
}

func Test_Named3(t *testing.T) { // OK
teardown := setup("Test_Named3")
t.Cleanup(teardown)
t.Parallel()

fn := testFn3

t.Run("Named3_Sub1", fn)

t.Run("Named3_Sub2", fn)
}

0 comments on commit 2a45336

Please sign in to comment.