We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If a test gets skipped in SetupTest() in a suite that implements WithStats, the suite will panic on shutdown.
package main import ( "testing" "github.com/stretchr/testify/suite" ) type mySuite struct { suite.Suite } func (s *mySuite) SetupTest() { s.T().Skip("Just because!") } func (s *mySuite) HandleStats(_ string, _ *suite.SuiteInformation) {} func (s *mySuite) TestSomething() { panic("Should not get here.") } func TestAll(t *testing.T) { suite.Run(t, &mySuite{}) }
It shouldn’t panic. It should probably just skip that test.
=== RUN TestAll === RUN TestAll/TestSomething main_test.go:14: Just because! panic.go:262: test panicked: runtime error: invalid memory address or nil pointer dereference goroutine 22 [running]: runtime/debug.Stack() /Users/felipe/.local/share/mise/installs/go/1.23.7/src/runtime/debug/stack.go:26 +0x64 github.com/stretchr/testify/suite.failOnPanic(0x140000b9380, {0x1024861c0, 0x102744ee0}) /Users/felipe/go/src/github.com/10gen/mongosync/vendor/github.com/stretchr/testify/suite/suite.go:89 +0x38 github.com/stretchr/testify/suite.recoverAndFailOnPanic(0x140000b9380) /Users/felipe/go/src/github.com/10gen/mongosync/vendor/github.com/stretchr/testify/suite/suite.go:83 +0x40 panic({0x1024861c0?, 0x102744ee0?}) /Users/felipe/.local/share/mise/installs/go/1.23.7/src/runtime/panic.go:791 +0x124 github.com/stretchr/testify/suite.SuiteInformation.end(...) /Users/felipe/go/src/github.com/10gen/mongosync/vendor/github.com/stretchr/testify/suite/stats.go:34
The text was updated successfully, but these errors were encountered:
Fix panic if a WithStats suite skips a test during SetupTest or Befor…
51c1e6a
…eTest. This fixes issue stretchr#1722.
Successfully merging a pull request may close this issue.
Description
If a test gets skipped in SetupTest() in a suite that implements WithStats, the suite will panic on shutdown.
Step To Reproduce
Expected behavior
It shouldn’t panic. It should probably just skip that test.
Actual behavior
The text was updated successfully, but these errors were encountered: