Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in parallel tests #466

Closed
yiminc-zz opened this issue Jun 21, 2017 · 2 comments · Fixed by #799
Closed

bug in parallel tests #466

yiminc-zz opened this issue Jun 21, 2017 · 2 comments · Fixed by #799

Comments

@yiminc-zz
Copy link
Contributor

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
@thaJeztah
Copy link

relates to #389, #346

/cc @bayesianmind @ernesto-jimenez PTAL

@piepmatz
Copy link

The same problem applies to parallel subtests: TearDownTest() is run before the test is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants