test-audit
Writing good tests
Tests should be robust to small implementation detail changes. They should focus on testing the public API or "seam" of a module or component within a codebase.
We should not write endless detailed unit tests with brittle assertions that test in great detail small implementation details that do not matter. I would prefer to have fewer tests with wider coverage than lots of detailed unit tests that are fragile.
Mocking
Aim for a test suite without mocks if possible. Prefer to integrate two components when testing how they integrate, over mocking the outside world.
Reaching for a mock is an indication that we are not testing the right thing. If you feel a mock object is a better approach, present your argument to the user and let them decide.
Methods or functions to test
Only test "public" methods and functions, that are called from other modules or packages. Do not test implementation details or helper methods - their behaviour and correctness should be proved from tests that exercise them from the public API of the system.
Pythoh
- Don't test methods or functions that start with an underscore "_"