Testing and QA · Beginner · 15 min
Choose what to test: the test pyramid, the trophy and risk
By Padding · Updated 18 Nov 2026
Any shared document or spreadsheet · November 2026
You will have a one-page test mix for a booking app that names its biggest risks, assigns each one to the cheapest kind of test that can catch it and gives a reason for every choice.
On this page
Every team has more things it could test than time to test them. The question is not "should we test?" but "which test, at which level, for which risk?". A suite with a thousand tests can still let the worst bug through if none of them look where the danger is.
This tutorial gives you a way to decide. You learn what four kinds of automated test catch and what each one costs, read two well-known shapes for a test suite (the pyramid and the trophy) as two answers to the same trade-off, and then work from the product's risks instead of from a shape. The running example is the Larkfield Clinic booking app, a fictional clinic app where patients pick a slot, pay a deposit and get a reminder. You end with a one-page test mix you can show your team.
You do not need to write any code. Bring a document and, if you have one, a product of your own to apply each step to.
Step 1 · Write down what each kind of test catches and costs
Start a table with four rows and four columns: test type, what it catches, what it cannot catch and cost. Cost here means three things: how long the test takes to run, how often it fails for reasons that are not bugs, and how much work it takes to keep it passing when the code changes.
Fill it in with your own words. For reference, this is how the four types compare:
- Unit tests check one function or module with its collaborators replaced. They catch logic errors: a price rounded the wrong way, a date one day out, a state change that should be refused. They cannot tell you whether the parts fit together. They run in milliseconds and rarely fail for no reason, so you can have hundreds.
- Integration tests run several real parts together, usually your code against a real database, queue or file system. They catch wrong queries, missing constraints, transactions that do not roll back and configuration mistakes. They take seconds and need the real dependency running.
- Contract tests check that two services agree on the shape of the messages between them: the app expects a
slotId, and the API really sends one. They catch breaking changes between teams or between your app and an API before release, without starting both sides together. They need both sides to keep the contract up to date. - End-to-end tests drive the whole product through its real interface, usually a browser or a phone. They catch problems no lower layer can see: a button that never enables, a redirect that loops, a page that loads but cannot be used. They are the slowest, the most likely to fail for timing reasons, and each one breaks when any part of its journey changes.
Two other kinds of check matter even though they are not "tests" in the usual sense. Static checks (type checkers and linters) catch typos and wrong types as you write. Manual checks, such as exploratory testing or trying the app with a screen reader, catch what nobody thought to automate.
Check it worked
Your table has four rows. Each row's "what it catches" column names at least one problem that no row above it can catch. If two rows say the same thing, rewrite them until they do not.
Step 2 · Read the pyramid and the trophy as one trade-off
The test pyramid, which Martin Fowler credits to Mike Cohn, says: write many unit tests, fewer integration tests and very few end-to-end tests. The reason is cost. Low tests are fast and stable, so they give you quick feedback on every change; high tests are slow and brittle, so you keep only the ones worth their price.
The testing trophy, from Kent C. Dodds, puts static checks at the base and the widest band at integration. His reasoning is that the more a test resembles the way the software is used, the more confidence it gives you, and modern tools have made integration tests cheaper than they were when the pyramid was drawn.
The shapes disagree about the middle, and they agree about the top. Neither is a rule. Each is a default someone drew for the kind of software they worked on. A library full of calculations suits the pyramid; a web app that is mostly forms over a database often suits the trophy. Your product's risks decide which one fits, which is what the rest of this tutorial works out.
Check it worked
Under your table, write one sentence for each shape in your own words, saying where it puts most of the effort and why. Then write one sentence on what both agree about. If you cannot write the third sentence, read the bottom line of the diagram again.
Step 3 · List the product's risks in plain language
A risk is something that could go wrong for a real person, and how bad it would be. Write each one as "what goes wrong, for whom". Avoid naming a test type yet; that comes next.
For the Larkfield booking app, a first list might be:
- Two patients book the same slot, and one turns up to find their appointment taken.
- A patient pays a deposit, but the booking stays "unpaid", or is marked paid when the payment failed.
- A patient using a screen reader or only a keyboard cannot finish a booking.
- The app and the clinic API disagree about a field after one of them changes, and bookings stop saving.
- Appointment times show wrongly for a patient whose phone is in another time zone, or around a clock change.
- The booking fails on a low-end Android phone on a slow or costly connection, because a request times out and the form loses what the patient typed.
Now give each risk two scores from 1 to 3: likelihood (how easily could this happen?) and impact (how bad is it when it does?). Multiply them. For Larkfield, double booking and payment state score highest: both happen under ordinary load, and both cost the clinic money and trust. Accessibility scores high on impact, because a patient who cannot book has no other way in after hours.
If your users include many people on prepaid data or older Android phones, as is common in Nigeria and across much of Africa, the slow-connection risk belongs near the top. Some payment methods, such as mobile money, also leave a payment pending while the patient approves it on their phone, which makes the payment-state risk more likely, not less.
Check it worked
You have between five and eight risks. Each one names a person and a consequence, and none of them mentions a test type. Each has a likelihood, an impact and a product of the two, and the list is sorted with the highest score first.
Step 4 · Map each risk to the cheapest test that can catch it
Work down your sorted list. For each risk, ask: what is the lowest layer at which a test could fail when this goes wrong? That layer is the main defence. Then ask whether another layer adds something the main one cannot see, and add it as a supporting check only if it does.
For Larkfield:
- Double booking. A unit test can check the rule "a slot holds one booking" in your code, but the real failure is two requests arriving at the same moment. Only a test against the real database, sending two bookings for one slot at once and expecting exactly one to succeed, proves the unique constraint or lock works. Main defence: integration. Supporting: a unit test for the slot rules, one end-to-end booking.
- Payment state. The states (pending, paid, failed, refunded) and the moves between them are logic. A unit test per allowed and refused move is fast and exhaustive. Supporting: a contract test that the payment provider's webhook payload still has the fields you read, an integration test that the webhook handler updates the database, and one end-to-end happy path.
- Screen reader cannot book. Automated scanners help but do not settle it: axe-core's own documentation says it finds on average 57% of WCAG issues, and flags others for a person to review. Main defence: a manual pass with a screen reader on the booking journey before each release. Supporting: an accessibility lint rule and an automated scan inside the end-to-end test.
- App and API disagree. This is what contract tests are for. Main defence: a contract test. Supporting: type checks on the shared fields.
- Times wrong across time zones. Pure date logic with a fixed clock. Main defence: unit tests with the time zone and the date set explicitly, including a clock-change date. Supporting: one integration test that times are stored in UTC.
- Fails on a slow phone. Hard to automate fully. Main defence: a manual check on a real low-end phone with a throttled connection. Supporting: an end-to-end test that runs with network throttling and checks the form keeps its values after a failed request.
Notice what the grid says about shape. Larkfield's main defences spread across unit, integration and manual, with end-to-end tests only as support. That is closer to a trophy than a pyramid, because its worst risks live where code meets the database and the user. A product whose worst risks are calculations would come out closer to a pyramid. The shape is the result of this step, not its input.
Check it worked
Every risk on your list has exactly one main defence and a sentence saying why that layer. No risk has end-to-end as its only defence when a lower layer could also fail for it. If one does, move the main defence down and keep the end-to-end test as support.
Step 5 · Decide what you will not test
A test mix is also a list of things you choose not to automate. Saying so out loud stops arguments later, and stops people writing tests that cost more than the bugs they would catch.
Add a short section headed Not tested, and why. For Larkfield it might say:
- The date-picker library's own behaviour: it has its own tests; we test that our screen passes it the right range.
- Marketing copy on the home page: changes weekly, and a wrong word is cheap to fix after release.
- Every combination of booking options in end-to-end tests: the combinations are covered by unit tests on the rules, and one end-to-end journey proves the screens connect.
- Admin reports: used by two staff members who report problems directly; reviewed by hand each month.
Check it worked
Your section has at least three items, and each one gives a reason that refers to cost, an existing check elsewhere, or low impact. "No time" on its own is not a reason; write what makes the risk acceptable.
Step 6 · Write the one-page test mix
Now put it together. Use these headings, and keep the whole thing to one page so people read it:
- Product and date. "Larkfield booking app, November 2026."
- Top risks. Your sorted list from the risk step, one line each.
- The mix, by layer. For each layer, what it is for in this product and roughly how much of it you expect. For Larkfield: static checks on every save; unit tests for booking rules, payment states and dates, the largest number of tests; integration tests against a real PostgreSQL database for bookings, payments and the webhook handler, the most effort per test; contract tests between the app and the clinic API, and on the payment webhook; three end-to-end journeys (book and pay, cancel, book with a screen-reader-friendly path checked by an automated scan); a manual screen-reader and slow-phone pass before each release.
- Not tested, and why. From the previous step.
- When to revisit. For example: after any incident, when a new payment method is added, and every three months.
Give numbers as rough proportions or counts, not targets to hit. "About three end-to-end journeys" tells a new team member far more than "70% unit tests", which says nothing about which risks are covered.
Check it worked
Hand the page to someone who has not seen your notes and ask: "If we add a new payment method, which tests would you add, and at which layer?" If they can answer from the page alone, it works. If they have to ask you, add the missing reason to the page.
Step 7 · Test the mix against real bugs
A mix built from imagined risks needs checking against what actually goes wrong. Take your last ten bugs, from your tracker, support messages or incident notes. For a new product with no history, take the bugs from a similar product or the last release of your previous one.
For each bug, write two things next to it: the layer in your mix that should have caught it, and whether that layer exists today. Three patterns are worth acting on:
- Several bugs land on one layer you do not have yet. That layer moves up your list of tests to write.
- A bug was caught only by a slow end-to-end test, but a unit or integration test could have caught it. Add the lower test; the end-to-end one may then be unnecessary.
- A bug fits no layer at all, such as a wrong setting in production. Note it as a release check, not a test.
Check it worked
Each of your ten bugs has a layer and a "have it / do not have it" mark. You have changed at least one line of your test mix because of what you found, or written down why none needed changing.
Next steps
You now have a test mix with reasons, built from your product's risks rather than from a shape. Write the tests it asks for next:
- Write end-to-end browser tests with Playwright, for the few journeys your mix keeps at the top.
- Write a one-page test strategy for a small product, to turn this mix into the standing decisions for your whole team.
Related tutorials
- Write bug reports that get fixedYou will turn three weak bug reports into ones a developer can act on in five minutes, and add a bug report form to a GitHub repository so every new report asks for the same facts.
- Write acceptance tests with Given, When, Then and pytest-bddYou will turn examples agreed with a product owner into Gherkin scenarios for a small room-booking module, wire them to pytest with pytest-bdd step definitions, parsers and fixtures, cover a rule table with a scenario outline, and judge when the extra layer pays for itself.
- Write a one-page test strategy for a small productYou will have a one-page test strategy for a small SaaS product that records the standing testing decisions, from quality goals and automation owners to release blockers, bug triage and what you deliberately leave untested.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials