Mocking is a process used in unit testing when the unit being tested has external dependencies. The purpose of mocking is to isolate and focus on the code being tested and not on the behavior or state of external dependencies. A mocking framework is a library that provides the ability to replace some components in your system with mock objects and make assertions about how they have been used. Go comes with built-in support for mocking: if you embed an interface in your struct, you can override it at will in your tests. Some great Go mocking libraries are testify - common assertions and mocks that plays nicely; go-sqlmock - Sql mock driver for golang to test database interactions; mockery - A mock code autogenerator for Golang.
Go 1190 Version:v0.164.0 License: Permissive (MIT)
Go 1188 Version:v0.28.0 License: Permissive (MIT)