Test strategy and audit

How many tests are enough? The test pyramid without dogma

The test pyramid helps you decide which rules to check independently and which to check through connected parts of a system. The number of tests alone does not tell you whether important risks are covered or the team receives results in time. A suitable suite combines fast checks of specific logic with verification of boundaries and user journeys. Let the product determine the balance rather than a universal percentage.

What the layers mean and where names mislead

The pyramid’s basic idea is simple: many narrowly focused tests and a smaller group that checks broader connections across the system. In The Practical Test Pyramid, Ham Vocke also points out that layer names can be imprecise. Agree within the team on what each test actually runs and which dependencies it replaces.

API and UI describe how you interact with the application. Integration and E2E describe the scope of verification. An API test can check one service with substituted dependencies or a process involving several real services. A UI test can check an isolated form with prepared responses without testing the whole application.

Alongside the label “API test”, record the boundary: “order service with a real database, payment service replaced”. That description explains what a passing result gives you confidence in. The article on API tests instead of UI tests compares these entry points in more detail.

Rules, connections and user behaviour

A unit test suits pure logic, such as calculating a discount or allowing an order to move to another state. You supply an input and check the result without a database, network, or browser. This lets you check boundary combinations directly. Testing a calculation does not confirm that the service actually calls it and saves the correct amount.

An integration test checks selected parts working together. For a service and database, it checks writes, reads, and data mapping. Replacing the database with an object in memory does not verify specific database queries or constraints. Software Engineering at Google also explains the distinction between scope and the resources a test needs to run.

Contracts can help at the boundary between two teams. The client, or consumer, tests its own code against a simulated provider. The provider then verifies the recorded expectations against its implementation. Pact describes the two checks separately. They do not replace verification of data persistence or the complete process. The article on contract testing covers selection of relevant versions.

A UI component test can check that a form displays an error and retains the user’s entered values. Component tests in Playwright can run an isolated component in a real browser. A broader end-to-end (E2E) test then checks a selected journey through connected parts, such as submitting an order and seeing its confirmation. Include any replaced external services in its description.

An illustrative order: what to check where

The following map is a proposal for an illustrative online shop, rather than the outcome of a particular project. It shows why simply moving a check to a lower level may leave related failures uncovered.

Rule or risk Direct check with a narrower scope Additional verification needed
A coupon changes the price correctly and respects its conditions Unit tests of the calculation and boundary values The service uses this calculation and saves the result. The UI displays the amount returned by the service.
An order is saved with the correct items Integration test of the service with a real test database Submitting the basket creates an order with the corresponding data.
The client understands payment states Consumer and provider contract, tests of state handling A selected integration checks delivery and processing of an event from the payment test environment.
The basket remains usable when a coupon is rejected UI component test with a controlled error response The real service returns the agreed error and the user can continue.
Confirmation is readable and operable Visual and accessibility checks of the relevant states Manual keyboard checks and a representative journey, according to risk.

You do not need to click through the whole purchase for every coupon combination. Keep a check of the connection between the entered coupon, the service’s calculation, and the displayed price, though. A wrong submitted field or use of an incorrect amount will not show up in an isolated calculation test.

An API check should verify the response content you need and the operation’s effect, rather than only a successful status code. Playwright supports direct requests and server postcondition checks after a browser action. Correct JSON from the server does not mean the browser can load it or the application displays it correctly.

For a request to another domain, for example, check the CORS rules that determine whether the browser makes the response available to the script. A direct HTTP client does not enforce these rules as a browser does. Verification must use the relevant page and API origins, meaning the combinations of protocol, domain, and port. Testing on the same local origin may miss the problem. MDN’s CORS documentation explains the mechanism.

The limits of test doubles

A dependency substitute, also called a test double, helps prepare the response you need. You can simulate a declined payment or an unavailable service. With Playwright’s network handling, a browser request can be fulfilled with a prepared response without contacting the API.

A passing result then confirms behaviour against the substitute. If it returns an old structure or simplifies errors, it may differ from the real service. Google’s guidance on test doubles describes the need for suitable fidelity to the implementation and additional tests using real dependencies.

For each substitute, record which properties it does not check and where you will verify them. For payments, those might include the response agreement, event signature, or behaviour on repeated delivery. A prepared success response is not evidence that the payment integration is connected correctly.

Appearance and accessibility are separate testing purposes

Visual comparison looks for a difference from an approved image. Playwright compares screenshots with a reference, and the rendering environment can affect the result. Update a reference image only after assessing the change. An image match does not confirm a correct calculation or keyboard operation.

An accessibility check can be part of a component test or a broader test. Playwright’s documentation on automated scans explains that they cannot find every problem. Supplement them with manual verification according to risk, such as focus order and keyboard use of a form. Do not add these checks to a strategy merely to give the diagram a particular shape.

Choosing the mix for the product

For an application with substantial calculation logic of its own, testing isolated rules thoroughly is worthwhile. For a product that mainly connects external systems, data interfaces, configuration, and services working together will account for more of the risk. Many simple unit tests may not compensate for a missing integration check.

For each risk, assess the impact of an error, the likelihood of failure, and where the error can be observed. Change frequency can be one input when estimating likelihood. Then choose the smallest scope that can reliably detect the error and add the necessary connection checks. Deliberate checks at several layers can be justified for a critical order or permission.

Clarify how you will distinguish a correct result from an incorrect one. That basis for judging a test’s result is known as the test oracle, also described in the ISTQB Test Analyst syllabus. If the team does not know how discounts should combine, more tests will not resolve the unclear rule. Agree on the behaviour with the product owner and prepare independent expected values. Copying the same calculation from the implementation into the test can repeat the same mistake.

Auditing the existing suite and moving checks gradually

Start with one important journey. For its tests, record the rule checked, real dependencies, substituted parts, and owner. Add execution time, recurring failures, and the reason for keeping each test. This will show whether twenty scenarios protect against different risks or repeat the same check.

When moving a particular rule, proceed as follows:

  1. Name the error the original test detects and the conditions it verifies.
  2. Add a narrower test and check that deliberately breaking the logic makes it fail.
  3. Decide which connection or UI behaviour check must remain.
  4. Remove the original duplication only after comparing coverage and results.

Track the time from a change to a useful result, the time needed to identify a failure’s cause, maintenance work, and the errors each layer detected or missed. Distinguish product defects from problems with test data or the environment. A shorter run or a smaller number of tests does not, by itself, confirm improvement.

The audit should produce a map of covered risks and a concrete adjustment to one part of the suite. If feedback becomes faster and the necessary checks remain, apply the same process to another journey.

Related topics

You might also be interested in

Let's clarify where automation has the greatest expected benefit

We will assess your testing process and suggest what to automate, what to keep manual and what to start with.