MCPcopy Create free account
hub / github.com/stretchr/testify / TestPanicsWithError

Function TestPanicsWithError

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

Source from the content-addressed store, hash-verified

1517}
1518
1519func TestPanicsWithError(t *testing.T) {
1520
1521 mockT := new(testing.T)
1522
1523 if !PanicsWithError(mockT, "panic", func() {
1524 panic(errors.New("panic"))
1525 }) {
1526 t.Error("PanicsWithError should return true")
1527 }
1528
1529 if PanicsWithError(mockT, "Panic!", func() {
1530 }) {
1531 t.Error("PanicsWithError should return false")
1532 }
1533
1534 if PanicsWithError(mockT, "at the disco", func() {
1535 panic(errors.New("panic"))
1536 }) {
1537 t.Error("PanicsWithError should return false")
1538 }
1539
1540 if PanicsWithError(mockT, "Panic!", func() {
1541 panic("panic")
1542 }) {
1543 t.Error("PanicsWithError should return false")
1544 }
1545}
1546
1547func TestNotPanics(t *testing.T) {
1548

Callers

nothing calls this directly

Calls 2

PanicsWithErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected