Show stack trace on panic

This commit is contained in:
Sergej Zagursky 2019-02-11 17:50:19 +03:00 committed by George Lesica
parent 3f658bd5ac
commit 10a9f47426

View File

@ -6,6 +6,7 @@ import (
"os" "os"
"reflect" "reflect"
"regexp" "regexp"
"runtime/debug"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -58,7 +59,7 @@ func (suite *Suite) Assert() *assert.Assertions {
func failOnPanic(t *testing.T) { func failOnPanic(t *testing.T) {
r := recover() r := recover()
if r != nil { if r != nil {
t.Errorf("test panicked: %v", r) t.Errorf("test panicked: %v\n%s", r, debug.Stack())
t.FailNow() t.FailNow()
} }
} }