Skip to content

006. Test coverage standard: 90% line and branch, CI hard-fail

  • Date: 2026-05-28 (amended 2026-11-17)
  • Status: Accepted
  • In the context of a Python backend (FastAPI + ingestion CLI) and a TypeScript SPA, developed by one or more contributors with agentic assistance,
  • facing the risk that generated or quickly-written code ships without meaningful test coverage, and the need for a clear, enforceable standard that applies to every contributor equally,
  • we decided for a two-floor coverage standard, enforced as a hard-fail step in CI on every PR: a 90% aggregate floor on combined line and branch coverage, and a 70% per-file floor on combined line and branch coverage for any non-excluded file, with exclusions defined in a companion policy maintained outside this ADR,
    • Branch coverage is included alongside line coverage because branch misses (uncovered if/else paths) are the most common source of untested error handling
    • Combined line and branch applies where the tool reports a combined figure; otherwise each reported metric meets both floors
    • 90% aggregate and 70% per-file are floors, not targets; coverage above the floors is fine, the floors are the minimum
    • The per-file floor prevents the aggregate from masking one or two badly-undertested files; a high-coverage module elsewhere should not “subsidize” an untested handler
    • Each stack is measured on its own, so a well-covered backend cannot subsidize an undertested SPA, or the reverse
    • The exclusion list is maintained in Coverage exclusion policy and can evolve without amending this ADR; exclusions exist for code that cannot be meaningfully unit-tested
  • and neglected
    • 80% threshold: common but leaves too much room for untested error paths in a codebase where Bedrock and DB calls are the primary failure surfaces
    • 100% threshold: impractical; forces trivial tests of boilerplate and slows development
    • Warning-only enforcement: offers no guarantee; contributors learn to ignore it
    • Aggregate-only enforcement (no per-file floor): was the original choice; revised because aggregate measurement allows one or two badly-undertested files to hide behind well-covered ones, defeating the floor’s purpose for the specific failure surfaces the standard exists to catch
    • Backend-only scope: leaves the SPA’s key handling and API wiring, which run in every user session, without a floor
  • to achieve a baseline confidence that the non-trivial logic is exercised by tests before merging,
  • accepting
    • Contributors must write tests before a PR can merge; generated code from agents is not exempt
    • Reaching 90% on the provider layer (Bedrock calls) requires stubbing; tests that hit deployed AWS services are excluded from the coverage run
    • The threshold may need revisiting if the codebase grows infrastructure-heavy modules that are difficult to unit-test

Each stack’s CI test job fails the PR when either floor is missed, and developers run the same check locally. The coverage tooling, its configuration, and the commands live in the app repo.

Changes to the exclusion list do not amend this ADR. The exclusion policy page is the source of truth for what is excluded and why; this ADR is the source of truth for the 90% aggregate floor, the 70% per-file floor, their scope, and hard-fail enforcement.

2026-11-17: Widens the floors’ scope from the backend to the backend and the SPA. Removes implementation detail, which belongs in the app repo and the exclusion policy.