What is the FIRST principle in unit testing?
Answer
The FIRST acronym describes properties of good unit tests: F — Fast: unit tests should run in milliseconds. A slow test suite discourages running tests frequently. If tests are slow, they're not unit tests (they might be integration tests with real I/O). I — Isolated/Independent: tests should not depend on each other or share state. Any test should be runnable alone in any order. R — Repeatable: same result every time, regardless of environment, time, or external state. No randomness without seed, no real time dependencies, no network calls. S — Self-validating: test produces a clear pass/fail result — no manual inspection of log output needed. The assertion determines pass/fail automatically. T — Timely (or Thorough): written at the right time — before or alongside the production code (TDD), not months later. Also interpreted as thorough — test the full range of behaviors including edge cases. These principles guide design decisions when writing tests.
Previous
What is the Red-Green-Refactor cycle in TDD?
Next
What is test coverage and what are the risks of over-relying on it?