Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions on how to best integrate with Testify? #21

Open
Marakai opened this issue Oct 21, 2022 · 2 comments
Open

Suggestions on how to best integrate with Testify? #21

Marakai opened this issue Oct 21, 2022 · 2 comments

Comments

@Marakai
Copy link

Marakai commented Oct 21, 2022

To my amazement and joy this worked from the outset on an M1 Mac in Goland with Go 1.19.1! Unlike another package I won't name.

My question now is, where the best place would be to integrate with Testify as the test framework?

Having to set up the mock in every single package that uses my to-be-monkeyed methods/funcs would be highly annoying (doable, but annoying).

Unfortunately Testify doesn't have a "super-test-setup" that you can do once and every Suite setup receives. At least as far as I saw in the doco.

Any ideas?

@Marakai
Copy link
Author

Marakai commented Oct 21, 2022

Note: I've now embedded a helper function to set up patchguards in SetupSuite() and unpatch in TearDownSuite(). That seems to work. Now I'm looking for a way to sequentially patch in different monkeys. As in, first call should call fakeMethod1(), second call should call fakeMethod2(), and so on.

Something like sm.PatchSequence(patchMe func(), returnMe ...func())

@cch123
Copy link
Owner

cch123 commented Apr 11, 2023

monkey patch is still a hack tool to do the test stuff, it has too many limitations, eg. cannot run tests in parallel, broken compatibility when update happen .etc

we only use it to do the patch when the mock is too hard to write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants