unit-testing
Principles for writing and reviewing unit tests in any language or test framework, meaning fast, in-process tests of one piece of behaviour reached through its public interface. Use this whenever you write, change, review or debug a test of a function, class, module or package that runs without a network, a database or another process. Use it when deciding what counts as the unit, what to assert, whether to use the real collaborator or a fake, stub or mock, how to name and lay out a test, or how much setup to share. Use it when a test broke although the behaviour did not change, when a test passes although the code is wrong, when a test is flaky or slow, or when code is "hard to test" and the fix on offer is to expose an internal or mock everything around it. Also use it when briefing someone else to write unit tests. It is about how to think, not about any one framework's API.
Pinned to revision d53dc7371d06, so it is the text this page describes rather than whatever the author pushed since.
Files
Every link opens the file at its source, pinned to the revision this page describes.