Blog

Which software tests should you write first? Follow the business risk

Which software tests should you write first? Follow the business risk

A practical way to choose regression tests for payments, permissions and integrations without chasing a coverage percentage.

A small change passes review and breaks a discount calculation. The obvious response is “we need more tests”. A more useful question is which test would have detected this mistake, at a reasonable maintenance cost, before the release.

When a project has little automated coverage, testing everything at once is rarely practical. Start with behaviour whose failure causes a meaningful loss or crosses a security boundary. That might be charging a customer twice, exposing another account’s records or silently dropping an order.

Describe the failure before choosing a test tool

Write a concrete example with an expected result. “Discounts work” is too vague. “A cancelled item does not count towards the minimum order value for this promotion” gives developers and business owners something they can review together.

Rank examples using impact, likelihood of change and difficulty of noticing a failure. A frequently edited pricing rule may deserve attention before a stable, low-impact display preference. Past incidents are useful evidence, but include plausible failures that have not happened yet. Label assumptions so they can be challenged.

Put the check close to the behaviour

RiskA useful first checkWhat still needs checking
Wrong pricing ruleA focused unit test with boundary casesCorrect inputs from the wider system
Incorrect database or API interactionAn integration test across that boundaryThe user’s complete workflow
Broken critical journeyA small end-to-end scenarioUncovered rules and failure paths

These checks complement each other. A browser test can confirm that checkout completes, but it is a cumbersome way to explore dozens of pricing combinations. A fast rule test cannot tell you whether the production route applies the rule at all. Choose the narrowest check that can observe the relevant failure, then cover important connections separately.

From risk to useful feedback; Name failure; Pick boundary; Check result; Review signals
Select checks by the failures they can detect. The diagram does not prescribe a fixed ratio of test types.

Permissions need negative examples

A successful login proves little about access control. Check that an unauthenticated request is rejected and that an authenticated user cannot read another account’s resource by changing an identifier. Use the API or service boundary where enforcement happens; hiding a button is not an access check.

For integrations, include repeated requests and a response that arrives too late. Is the result duplicated? Does a rejected operation remain visible? Keep external dependencies controlled enough that a vendor outage does not turn the entire suite into unexplained noise.

Keep the feedback believable

A test that fails intermittently trains people to ignore failures. Give it an owner, record the cause and repair or replace it. Temporarily isolating a noisy test should be an explicit decision with a review date, not a way to present an incomplete suite as full protection.

Code coverage can show unexecuted paths, but a high percentage does not prove that assertions would catch a wrong result. Review what the checks establish. After a production defect, add the smallest useful regression check and ask why the earlier feedback missed it. A growing suite earns its cost when failures are understandable and releases carry less uncertainty.

Sources and documentation