General Guidelines
- Prefer End-to-End tests over unit tests.
- Test the API exposed by the application instead of small parts of the code.
- Start services required for a test instead of mocking them out (e.g. start the database as a Docker container).
- Use mocks where no binary of a required service exists (e.g. AWS API).
- Use BDD tools to write End-to-End tests.
Decision Helpers
Write a unit test if the code to test
- contains complicated logic.
- depends on code in the same namespace only (e.g. the same package in Go or the same module in Python).
If not all of the above points are met, a End-to-End test is usually better.