-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: fixing suite teardown ordering issue
(cherry picked from commit 92c097a5af7b4bbbe3a66c2e7484f68194cd555a)
- Loading branch information
Dinesh Kumar
committed
Aug 2, 2019
1 parent
221dbe5
commit d0039c3
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package suite | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type CallOrderSuite struct { | ||
Suite | ||
callOrder []string | ||
} | ||
|
||
func (s *CallOrderSuite) call(method string) { | ||
// s.Mutex.Lock() | ||
// defer s.Mutex.Unlock() | ||
|
||
s.callOrder = append(s.callOrder, method) | ||
} | ||
|
||
func TestSuiteCallOrder(t *testing.T) { | ||
Run(t, new(CallOrderSuite)) | ||
} | ||
func (s *CallOrderSuite) SetupSuite() { | ||
s.call("SetupSuite") | ||
} | ||
|
||
func (s *CallOrderSuite) TearDownSuite() { | ||
s.call("TearDownSuite") | ||
assert.Equal(s.T(), "SetupSuite;SetupTest;Test A;TearDownTest;TearDownSuite", strings.Join(s.callOrder, ";")) | ||
} | ||
func (s *CallOrderSuite) SetupTest() { | ||
s.T().Parallel() | ||
s.call("SetupTest") | ||
} | ||
|
||
func (s *CallOrderSuite) TearDownTest() { | ||
s.call("TearDownTest") | ||
} | ||
|
||
func (s *CallOrderSuite) Test_A() { | ||
s.call("Test A") | ||
} | ||
|
||
//func (s *CallOrderSuite) Test_B() { | ||
// time.Sleep(time.Second) | ||
// s.call("Test B") | ||
//} |