Awesome Mocks to Use in Go Tests

February 11, 2019 Testing

Go has a built-in support for unit testing. Writing tests is easy: just create some *_test.go files with func Test*(testing *T) functions. While providing a wide set of methods, the standard library does not have any mocks to use in tests. For example, there’s no common way to substitute os package behaviour without using third-party libraries or running the tests in a Docker container.

Mock implementations

Fortunately, there are some open-source libraries that provide mock objects. Here’s a list of them:

Anything else?

Feel free to mention me on Twitter if you know any other good libraries!

comments powered by Disqus