func TestPanicInHandler(t *testing.T) {
	buffer := new(bytes.Buffer)
	router := New()
	router.Use(RecoveryWithWriter(buffer))
	router.GET("/recovery", func(_ *Context) {
		panic("Oupps, Houston, we have a problem")
	})
	w := performRequest(router, "GET", "/recovery")
	assert.Equal(t, w.Code, 500)
	assert.Contains(t, buffer.String(), "GET /recovery")
	assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem")
	assert.Contains(t, buffer.String(), "TestPanicInHandler")
}
TestPanicInHandler assert that panic has been recovered.
package gin
import (
	"bytes"
	"testing"
	"github.com/stretchr/testify/assert"
)