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

Function TestPanicsWithError

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

Source from the content-addressed store, hash-verified

1585}
1586
1587func TestPanicsWithError(t *testing.T) {
1588 t.Parallel()
1589
1590 mockT := new(testing.T)
1591
1592 if !PanicsWithError(mockT, "panic", func() {
1593 panic(errors.New("panic"))
1594 }) {
1595 t.Error("PanicsWithError should return true")
1596 }
1597
1598 if PanicsWithError(mockT, "Panic!", func() {
1599 }) {
1600 t.Error("PanicsWithError should return false")
1601 }
1602
1603 if PanicsWithError(mockT, "at the disco", func() {
1604 panic(errors.New("panic"))
1605 }) {
1606 t.Error("PanicsWithError should return false")
1607 }
1608
1609 if PanicsWithError(mockT, "Panic!", func() {
1610 panic("panic")
1611 }) {
1612 t.Error("PanicsWithError should return false")
1613 }
1614}
1615
1616func TestNotPanics(t *testing.T) {
1617 t.Parallel()

Callers

nothing calls this directly

Calls 2

PanicsWithErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected