stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.48k stars 1.56k forks source link

Proposal: `testify.PanicsWithErrorRegex` #1304

Open stdedos opened 1 year ago

stdedos commented 1 year ago

Somewhat-related to https://github.com/stretchr/testify/issues/323, I'd like to be able to specify a regex (or a anonymous function callback) to verify "conformance" of the expected panic.

Differently to the issue above, I cannot work with the error outside require.Panics, since Testify swallows it.

dolmen commented 11 months ago

assert.Panics definitely lacks flexibility in matching the recovered value as PanicTestFunc doesn't receives it. Bad API design 😕