Creating mock objects for data repositories is a common requirement in web application development. In this article, I will show you how to use GoMock to automatically generate mocks for your interfaces and use them inside unit tests. When you have a service that depends on a repository to fetch some data, this repository will most likely be connected to a database. A typical sequence of events could look like this: Service A requests an object X from repository B ...

Bernhard Knasmüller on Software Development