We have worked with teams of 3 engineers and teams of 30. The testing strategy that actually works is the same in both cases, and it is not "write tests for everything".
Chasing 100% coverage is one of the most expensive mistakes a small team can make. It produces a large, slow, brittle test suite that gives false confidence and slows down every deployment.
Here is what we actually do instead.
01The problem with coverage as a goal
Coverage measures which lines were executed by tests. It does not measure whether those tests would catch a real bug. A test that runs a function and asserts nothing contributes to coverage and catches nothing.
We tracked this on one project: 92% coverage, and we still shipped three regressions in a month. The code was "covered" — it was just not tested.
Coverage is a useful diagnostic (it shows what is not touched at all), but a terrible goal.
02The strategy we actually use
We split tests into three categories and spend effort roughly in this ratio:
- ~10% of effort: unit tests for pure functions and business rules
- ~30% of effort: integration tests for database, HTTP, queue interactions
- ~60% of effort: end-to-end tests for the critical user journeys
- The checkout flow from "add to cart" through "order confirmation"
- User registration with email verification
- Password reset from request to successful login
- Payment authorization and refund
- Data export (because data loss is an incident)
- Unit tests run in under 5 seconds total. If a test needs a database, it is an integration test — move it to the right folder.
- Integration tests run in under 60 seconds. Each test wraps itself in a transaction that rolls back. No shared fixtures across tests.
- E2E tests run in parallel across CI runners. If the suite takes more than 5 minutes, split it.
- 340 unit tests: 3.1 seconds total
- 87 integration tests: 41 seconds total
- 19 E2E tests: 2 minutes 20 seconds, parallelized across 4 runners
- Framework code. We do not test that Laravel's router routes. Laravel tests that.
- Trivial getters and setters. Coverage-padding with no value.
- Third-party SDKs. We mock them and test our usage, not their behavior.
- Configuration files. If
config/app.phphas a typo, you find out in staging, not from a test. - Average coverage dropped from ~85% to ~70%
- Production regressions per release dropped by about 60%
- CI runtime dropped by about 40%
- Developer time spent on tests dropped by about 30%
This is often the reverse of what teams do. Most small teams write mostly unit tests (fast, easy, high coverage numbers) and few integration or E2E tests (slow, flaky, hard to write). But the bugs that actually hurt live at the integration and E2E layer.
03What we test at each layer
Unit tests cover things like: price calculation rules, date arithmetic, permission logic, parsers, and formatters. Pure input/output. No database, no network, no time dependence.
Integration tests cover things like: a controller that writes to the database, a queue job that processes and updates state, an external API client wrapped in a fake. These catch the majority of "it worked locally" bugs.
E2E tests cover the critical user journeys: signup, login, checkout, payment, password reset. If one of those breaks, it is an incident. We test them through the real HTTP layer with a real (test) database.
04The "critical path" rule
If a bug on a code path would be a P1 incident, it gets an E2E test. No exceptions. If it would be a minor annoyance, a unit test is enough. If it would be invisible to users, we may not test it at all.
Examples of critical paths from recent projects:
Everything else is tested as a function of how painful the bug would be, not as a function of how easy the test is to write.
05The rules that keep tests fast
A slow test suite is an unrun test suite. Our rules:
Our current project test counts (a mid-sized SaaS):
Total CI time for the full suite: under 4 minutes.
06Flaky tests are bugs, not noise
The moment a team starts saying "oh, that test is flaky, just re-run it", the test suite has lost its value. Every flaky test is either a bug in the test or a real race condition in the code. Both need to be fixed, not muted.
We have a rule: if a test fails twice for no obvious reason, it is quarantined and fixed within the same week. A quarantined test blocks the responsible engineer from any non-critical work until it is fixed.
It sounds harsh. It is the only thing that has ever kept a test suite trustworthy.
07What we do not test
Skipping these saves weeks of effort and loses almost nothing.
08The honest results
Since we adopted this strategy (about two years ago), across roughly 25 projects:
Less testing effort, fewer bugs. The strategy works because it targets the tests that actually catch bugs instead of the ones that pad numbers.
09The takeaway
If you are a small team, stop optimizing for coverage. Start optimizing for "which bugs would hurt most, and do we have a test that would catch that specific bug?"
The answer will almost always point you at integration and end-to-end tests, not more unit tests. And that is where you should spend your time.