Open
Description
Consider the following example:
type Suite struct {
suite.Suite
}
func (s *Suite) TearDownSuite() {
s.T().Log(">>>>>> suite tear down")
}
func (s *Suite) TearDownTest() {
s.T().Log(">>>>>> single test tear down")
}
func (s *Suite) TestOne() {
for _, v := range []string{"sub1", "sub2", "sub3"} {
s.Run(v, func() {
s.T().Parallel()
})
}
}
func (s *Suite) TestTwo() {
for _, v := range []string{"sub1", "sub2", "sub3"} {
s.Run(v, func() {
s.T().Parallel()
})
}
}
func TestLogic(t *testing.T) {
suite.Run(t, &Suite{})
}
After executing that you would get an output similar to this:
=== RUN TestLogic
=== RUN TestLogic/TestOne
=== RUN TestLogic/TestOne/sub1
=== PAUSE TestLogic/TestOne/sub1
=== RUN TestLogic/TestOne/sub2
=== PAUSE TestLogic/TestOne/sub2
=== RUN TestLogic/TestOne/sub3
=== PAUSE TestLogic/TestOne/sub3
TestLogic/TestOne: prog.go:18: >>>>>> single test tear down
=== CONT TestLogic/TestOne/sub1
=== CONT TestLogic/TestOne/sub3
=== CONT TestLogic/TestOne/sub2 >>> test finished here
=== RUN TestLogic/TestTwo
=== RUN TestLogic/TestTwo/sub1
=== PAUSE TestLogic/TestTwo/sub1
=== RUN TestLogic/TestTwo/sub2
=== PAUSE TestLogic/TestTwo/sub2
=== RUN TestLogic/TestTwo/sub3
=== PAUSE TestLogic/TestTwo/sub3
TestLogic/TestTwo: prog.go:18: >>>>>> single test tear down
=== CONT TestLogic/TestTwo/sub1
=== CONT TestLogic/TestTwo/sub3
=== CONT TestLogic/TestTwo/sub2 >>> test finished here
TestLogic: prog.go:14: >>>>>> suite tear down
Live example: https://play.golang.com/p/fPY3DZFNNok
It is clear that TearDownTest is being executed before all parallel sub tests finish. I see that a similar issue was addressed in #799 and #466 but not resolved in its entirety.
The version in use is 1.5.1
Activity