📖 3 min read (~ 600 words).

Panic

Asserting A Panic Behavior

Assertions

GoDoc

All links point to https://pkg.go.dev/github.com/go-openapi/testify/v2

This domain exposes 4 functionalities.

NotPanics

NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.

Examples
	assertions.NotPanics(t, func(){ RemainCalm() })
	success: func() { }
	failure: func() { panic("panicking") }

Panics

Panics asserts that the code inside the specified PanicTestFunc panics.

Examples
	assertions.Panics(t, func(){ GoCrazy() })
	success: func() { panic("panicking") }
	failure: func() { }

PanicsWithError

PanicsWithError asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison.

Examples
	assertions.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
	success: ErrTest.Error(), func() { panic(ErrTest) }
	failure: ErrTest.Error(), func() { }

PanicsWithValue

PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.

Examples
	assertions.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
	success: "panicking", func() { panic("panicking") }
	failure: "panicking", func() { }


Generated with github.com/go-openapi/testify/v2/codegen