β οΈ This post links to an external website. β οΈ
No shade against mocking libraries like gomock or mockery. I use them all the time, both at work and outside. But one thing Iβve noticed is that generating mocks often leads to poorly designed tests and increases onboarding time for a codebase.
Also, since almost no one writes tests by hand anymore and instead generates them with LLMs, the situation gets more dire. These ghosts often pull in all kinds of third-party libraries to mock your code, simply because they were trained on a lot of hastily written examples on the web.
So the idea of this post isnβt to discourage using mocking libraries. Rather, itβs to show that even if your codebase already has a mocking library in the dependency chain, not all of your tests need to depend on it. Below are a few cases where I tend not to use any mocking library and instead leverage the constructs that Go gives us.
This does require some extra song and dance with the language, but in return, we gain more control over our tests and reduce the chance of encountering spooky action at a distance.
continue reading on rednafi.com
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.