A helper that one test file uses stays in that file. A helper that more
than one test file uses goes into a file without tests, whose name says
what it holds and ends with _helper_test.go. The name then shows that
the file has no tests, and a file named for one type does not seem to
test a feature of that name.
input.
- In a test file, put constants immediately after the imports, then the
tests, then supporting types, methods, and helpers.
+- Keep a helper that only one test file uses in that file. Put a helper
+ that more than one test file uses in a file without tests. Name that
+ file for what it holds, and end the name with `_helper_test.go`.
- Supply valid required dependencies in tests. Do not make a dependency
optional only to make a test simpler.