MCPcopy
hub / github.com/stretchr/testify / Panics

Function Panics

assert/assertions.go:1300–1310  ·  assert/assertions.go::Panics

Panics asserts that the code inside the specified PanicTestFunc panics. assert.Panics(t, func(){ GoCrazy() })

(t TestingT, f PanicTestFunc, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1298//
1299// assert.Panics(t, func(){ GoCrazy() })
1300func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
1301 if h, ok := t.(tHelper); ok {
1302 h.Helper()
1303 }
1304
1305 if funcDidPanic, panicValue, _ := didPanic(f); !funcDidPanic {
1306 return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
1307 }
1308
1309 return true
1310}
1311
1312// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
1313// the recovered panic value equals the expected panic value.

Calls 3

didPanicFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65