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

Function TestPanicsWithValue

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

Source from the content-addressed store, hash-verified

1556}
1557
1558func TestPanicsWithValue(t *testing.T) {
1559 t.Parallel()
1560
1561 mockT := new(testing.T)
1562
1563 if !PanicsWithValue(mockT, "Panic!", func() {
1564 panic("Panic!")
1565 }) {
1566 t.Error("PanicsWithValue should return true")
1567 }
1568
1569 if !PanicsWithValue(mockT, nil, func() {
1570 panic(nil)
1571 }) {
1572 t.Error("PanicsWithValue should return true")
1573 }
1574
1575 if PanicsWithValue(mockT, "Panic!", func() {
1576 }) {
1577 t.Error("PanicsWithValue should return false")
1578 }
1579
1580 if PanicsWithValue(mockT, "at the disco", func() {
1581 panic("Panic!")
1582 }) {
1583 t.Error("PanicsWithValue should return false")
1584 }
1585}
1586
1587func TestPanicsWithError(t *testing.T) {
1588 t.Parallel()

Callers

nothing calls this directly

Calls 2

PanicsWithValueFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected