Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Mocking is done using which generates mocks using

What not to do
  • Do not write a 'custom' mock - eg, write a struct which implements the interface you want to mock. If somebody needs to change the interface further down the line, they will then need to modify your mock as well. When using an autogenerated mock, they can just run 'go generate' to recreate it.
  • Do not use a mock for an interface in the same package. Mocks should provide a description of the interface for something in the package - the package itself should not need to test the mock.
Generating mocks

When adding a new interface that will require a mock there are a few simple steps to follow