Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ func Run(t *testing.T, suite TestingSuite) {
suite.SetT(t)
suite.SetS(suite)

var suiteSetupDone bool

var stats *SuiteInformation
if _, ok := suite.(WithStats); ok {
stats = newSuiteInformation()
Expand All @@ -152,18 +150,6 @@ func Run(t *testing.T, suite TestingSuite) {
continue
}

if !suiteSetupDone {
if stats != nil {
stats.Start = time.Now()
}

if setupAllSuite, ok := suite.(SetupAllSuite); ok {
setupAllSuite.SetupSuite()
}

suiteSetupDone = true
}

test := test{
name: method.Name,
run: func(t *testing.T) {
Expand Down Expand Up @@ -208,19 +194,30 @@ func Run(t *testing.T, suite TestingSuite) {
}
tests = append(tests, test)
}
if suiteSetupDone {
defer func() {
if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
tearDownAllSuite.TearDownSuite()
}

if suiteWithStats, measureStats := suite.(WithStats); measureStats {
stats.End = time.Now()
suiteWithStats.HandleStats(suiteName, stats)
}
}()

if len(tests) == 0 {
return
}

if stats != nil {
stats.Start = time.Now()
}

if setupAllSuite, ok := suite.(SetupAllSuite); ok {
setupAllSuite.SetupSuite()
}

defer func() {
if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
tearDownAllSuite.TearDownSuite()
}

if suiteWithStats, measureStats := suite.(WithStats); measureStats {
stats.End = time.Now()
suiteWithStats.HandleStats(suiteName, stats)
}
}()

runTests(t, tests)
}

Expand Down