Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
11 changes: 9 additions & 2 deletions suite/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ func (s *SuiteInformation) end(testName string, passed bool) {
if s == nil {
return
}
s.TestStats[testName].End = time.Now()
s.TestStats[testName].Passed = passed

testStats, started := s.TestStats[testName]

if !started {
return
}

testStats.End = time.Now()
testStats.Passed = passed
}

func (s *SuiteInformation) Passed() bool {
Expand Down
29 changes: 29 additions & 0 deletions suite/suite_stats_and_skip_test.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a new test file for this?
I feel like we can put this in the existing test file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too. You might also find there's an existing substitute for mySuite.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the test to suite/suite_test.go and renamed mySuite to a more descriptive suiteSkipTestWithStats

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package suite

import (
"testing"

"github.com/stretchr/testify/assert"
)

type mySuite struct {
Suite
}

func (s *mySuite) SetupTest() {
s.T().Skip("Just because!")
}
func (s *mySuite) HandleStats(_ string, _ *SuiteInformation) {}

func (s *mySuite) TestSomething() {
panic("Should not get here.")
}

func TestSuiteWithStatsAndSkip(t *testing.T) {
assert.NotPanics(
t,
func() {
Run(t, &mySuite{})
},
)
}