mirror of
https://github.com/stretchr/testify.git
synced 2025-07-13 15:48:34 +00:00
Merge pull request #1502 from stretchr/suite-fix-reporting-of-panic-location
suite: fix recoverAndFailOnPanic to report test failure at the right location
This commit is contained in:
commit
c3b0c9b4f5
@ -78,11 +78,13 @@ func (suite *Suite) Assert() *assert.Assertions {
|
||||
}
|
||||
|
||||
func recoverAndFailOnPanic(t *testing.T) {
|
||||
t.Helper()
|
||||
r := recover()
|
||||
failOnPanic(t, r)
|
||||
}
|
||||
|
||||
func failOnPanic(t *testing.T, r interface{}) {
|
||||
t.Helper()
|
||||
if r != nil {
|
||||
t.Errorf("test panicked: %v\n%s", r, debug.Stack())
|
||||
t.FailNow()
|
||||
@ -165,6 +167,8 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||
suite.SetT(t)
|
||||
defer recoverAndFailOnPanic(t)
|
||||
defer func() {
|
||||
t.Helper()
|
||||
|
||||
r := recover()
|
||||
|
||||
if stats != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user