go-best-practices icon indicating copy to clipboard operation
go-best-practices copied to clipboard

Testing Section Improvements

Open GeorgeMac opened this issue 7 years ago • 3 comments

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.

GeorgeMac avatar Jul 15 '17 17:07 GeorgeMac

📎 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.

brettbuddin avatar Jul 16 '17 00:07 brettbuddin

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.

GeorgeMac avatar Sep 01 '17 08:09 GeorgeMac

Opened PR https://github.com/codeship/go-best-practices/pull/12 to cover mocking discussion

GeorgeMac avatar Sep 06 '17 16:09 GeorgeMac