go-best-practices
go-best-practices copied to clipboard
Testing Section Improvements
What I think we need to add in order to feel that testing is complete for now.
- [x] mocking and interfaces
- [ ] integration testing
- [ ] code reuse (i.e. to avoid it where possible)
- [ ] fixtures in tests
- [ ] naming conventions for tests
Please contribute to this Issue thread so that we can track here the topics we want to talk about.
📎 https://rakyll.org/naming-tests-to-doc/
Naming of tests is important. We should converge on some naming conventions for tests and subtests.
I've made the mistake that Hashimoto described in his talk regarding indices as names: https://github.com/brettbuddin/musictheory/blob/master/chord_test.go. This was pre-Subtest code, but you get the idea. I'd like to avoid that kind of behavior in the future.
Currently the consensus is we do not use mocking libraries.
We feel that we are equipped with everything we need, via just using interfaces + structs.
The section on mocking should document this practice.
Opened PR https://github.com/codeship/go-best-practices/pull/12 to cover mocking discussion