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

Function TestDidPanic

assert/assertions_test.go:1518–1539  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1516}
1517
1518func TestDidPanic(t *testing.T) {
1519 t.Parallel()
1520
1521 const panicMsg = "Panic!"
1522
1523 if funcDidPanic, msg, _ := didPanic(func() {
1524 panic(panicMsg)
1525 }); !funcDidPanic || msg != panicMsg {
1526 t.Error("didPanic should return true, panicMsg")
1527 }
1528
1529 if funcDidPanic, msg, _ := didPanic(func() {
1530 panic(nil)
1531 }); !funcDidPanic || msg != nil {
1532 t.Error("didPanic should return true, nil")
1533 }
1534
1535 if funcDidPanic, _, _ := didPanic(func() {
1536 }); funcDidPanic {
1537 t.Error("didPanic should return false")
1538 }
1539}
1540
1541func TestPanics(t *testing.T) {
1542 t.Parallel()

Callers

nothing calls this directly

Calls 2

didPanicFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected