From 57f0a61e1a93be0a3d5357df7b65171ca487f2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 21 Mar 2025 13:38:55 +0100 Subject: [PATCH] Warn against usage inside a gouroutine mockery relies on testify APIs that are not safe to use from outside the goroutine that runs the test function. See https://github.com/stretchr/testify/pull/1710 --- docs/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/index.md b/docs/index.md index 7f54fd684..de85b4d6f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -71,6 +71,14 @@ Why use mockery over gomock? 4. mockery's CLI is more robust, user-friendly, and provides many more options 5. mockery supports generics (this may no longer be an advantage if/when gomock supports generics) +Warning about goroutine safety +------------------------------ + +As mentioned earlier, mockery relies on `testify`, which comes with a limitation: +calling an unexpected method on a mock object can cause necessary cleanups such +as channel closing to be skipped. This means that ideally, mock objects should +only ever be used from the same goroutine that runs the test function. + Who uses mockery? ------------------