-
Notifications
You must be signed in to change notification settings - Fork 1.7k
bug in parallel tests #466
Copy link
Copy link
Closed
Labels
Description
When enable parallel testing, we would expect the TearDownSuite() to be called after all the tests completed. However, after this commit, 3104bf5
the parallel testing is broken as the TearDownSuite() is called before tests are done.
Here is a simple repro code to repro:
type MyTestSuite struct {
suite.Suite
}
func TestMySuite(t *testing.T) {
suite.Run(t, new(MyTestSuite))
}
func (s *MyTestSuite) SetupSuite() {
fmt.Println("SetupSuite")
}
func (s *MyTestSuite) TearDownSuite() {
fmt.Println("TearDownSuite")
}
func (s *MyTestSuite) SetupTest() {
s.T().Parallel()
fmt.Println("SetupTest")
}
func (s *MyTestSuite) TearDownTest() {
fmt.Println("TearDownTest")
}
func (s *MyTestSuite) Test_A() {
time.Sleep(time.Second)
}
func (s *MyTestSuite) Test_B() {
time.Sleep(time.Second * 2)
}
The output of above tests is:
SetupSuite
TearDownSuite
SetupTest
SetupTest
TearDownTest
TearDownTest
Reactions are currently unavailable