Hi,
I've been waiting for a mocking library for Go unit tests to be
written, but as yet I've not seen any turn up in any searches, so I
gave up waiting and wrote a quick attempt at one. This library is not
in a feature-complete state, but I would like to put it out early
before I invest too much time into it in order to get some opinions
and suggestions on how I could better the approach taken in this
library.
It is available via:
https://github.com/huin/gomock
goinstall
github.com/huin/gomock
Or in Go code with: import "
github.com/huin/gomock"
The objective is to testing calls made upon objects that fulfill a
given interface. This requires code generation for a mock type per
interface type that needs to be mocked. Currently this must be written
by hand, but hopefully a code-generator can be written at some stage.
Features that are obviously missing in this library at present:
* A complete Eq() comparator that can manage more than a few types.
* A more complete set of comparators.
* Any kind of optimization (if that's even desirable).
* Integration with test suites other than the "testing" package in the
Go standard library.
Possible features might include setting constraints upon expected call
order.
Thoughts/opinions?
Thanks,
- John