Quality & Team

Testing Strategy

Foundational

Tests let us change code with confidence. A good test suite gives fast feedback, catches regressions before customers do, and shows how the system should behave. A bad suite is slow, flaky, and tests the mocks instead of the behaviour. Aim your testing at risk: the logic that, if wrong, costs money, leaks data, or breaks compliance.

The strategy is the test pyramid: many fast unit tests over individual logic, fewer integration tests over how components fit together (especially data access and external boundaries), and a small number of end-to-end tests over critical journeys. Test at the lowest level you can. Use unit tests where possible, and integration tests where the interaction is the risk. This keeps the suite fast and stable.

Coverage is a means, not the goal. A high percentage of trivial getters proves little. What matters is that the high-risk behaviour is tested for the cases that cause real harm: the fail-closed path when screening errors, the tenant-isolation boundary, the idempotent retry, and the money calculation. On a regulated platform, the test suite is also evidence that critical controls behave as required.

Test the right things, the right way

Testing only the happy path [Fact] void Approves_clean_customer() {
screening.Setup(s => s.Check(any)).Returns(Clear);
Assert.Equal(Approved, sut.Onboard(customer));
}

Only the everything-works case is covered. The dangerous path, what happens when screening errors or times out, is exactly the one that must fail closed, and it is untested.

Pin the fail-closed behaviour [Fact] void Escalates_when_screening_unavailable() {
screening.Setup(s => s.Check(any)).Throws();
Assert.Equal(BlockAndEscalate, sut.Onboard(customer)); // never Approved
}

The test proves the AML-critical rule: when the check cannot complete, the customer is held, never auto-approved. A regression here now fails the build.

Keep the suite trustworthy

Self-review checklist

Why it matters: Tests let us move fast without breaking things. They catch regressions cheaply and give us the confidence to refactor. Aimed at the high-risk logic, they also serve as evidence that critical controls (fail-closed decisions, tenant isolation, money handling) behave correctly. That is exactly what a regulated platform must be able to show.