vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
6k stars 405 forks source link

Allow injection of GinkgoRecover into mock function definitions #411

Open Brian-McM opened 2 years ago

Brian-McM commented 2 years ago

Hi,

I currently have a problem where if the interface that I'm mocking out is called in a go routine the stack trace of a panic due to the mock not "expecting the call" will not contain the test that it failed on (which makes sense in general since the stack trace can only really go up to the start of the routine, not to what invoked it). I may have 10-100 different tests all mocking the same function for the same mock so it's very difficult to figure out which test actually mocked the function incorrectly (or didn't mock it).

I'm testing with ginkgo, and if you call GinkgoRecover() in the go routine that panics then it will include the test that it panicked on.

I was wondering if there is a way to a GinkgoRecover() into the start of all the mocked functions created for an interface. I'm also open to other suggestions for getting the test that failed.

Brian-McM commented 5 months ago

Hi, I just wanted to ping on this issue, would be nice to have a way to trace these cases to the test.