Automated testing for web applications: what to test and when

  • Home
  • Automated testing for web applications: what to test and when
Automated testing for web applications: what to test and when

Automated tests for a web application are scripts that check on their own, after every code change, whether the most important features still work. In a contract with a software house it is good to have at least three things: unit tests, end-to-end tests for critical paths, and running them in a CI pipeline.

I am writing this guide for the client who does not read code but still has to assess the quote and the scope of testing. You will find here the types of tests described in plain language, the order of automation and a list of questions for your vendor.

What are automated tests for a web application and why does the client need them?

It is code that checks other code. It runs by itself, with no tester clicking through screens. A manual tester goes through the scenario from scratch every time, and with frequent changes simply cannot keep up (or skips something because it is Friday after 4 p.m.). An automated test repeats the same steps identically, in a few minutes, with every fix.

What does the company get out of it? Fewer bugs in production, calmer releases of new features and an easier change of vendor in the future, because the new team sees right away what it breaks. Tests are part of quality, not an extra. And skipping them is one of the typical problems we cover when writing about mistakes in building web applications.

Types of tests: unit, integration, end-to-end and regression

Each type checks the application at a different level, from a single function to a full user path. You need to know the differences, because in quotes the names are often used interchangeably:

  • Unit tests - check one function in isolation, e.g. calculating a price with a discount. They run in fractions of a second. Developers write them, often in tools such as PHPUnit or Jest.
  • Integration tests - verify how the parts work together: the application with the database, with the payment gateway, with an external API. They are slower because they involve several systems at once.
  • End-to-end tests (E2E) - pretend to be a person in a browser and go through the whole path, from the click to the result. Example tools are Playwright and Cypress. They take the longest and are written by developers or test automation engineers.
  • Regression tests - this is not a separate technique but a goal: making sure a new change has not broken something that used to work. It is achieved by the full set of the tests above run together.

The test pyramid: how much of each you need

The rule is simple. Most tests should be fast unit tests, fewer should be integration tests and the fewest should be slow E2E tests, which are expensive to maintain. A project based on E2E alone? Long waits for the result, tests falling apart with every change in appearance and tedious hunting for the cause of a bug. Unit tests alone are not enough either, because they will not catch problems where modules meet or in the browser. And watch out for a code coverage percentage written into the contract as a standard. It only tells you how much code was executed. It does not tell you whether what matters to the business was checked.

What to automate first? The critical paths of the application

First come the paths whose failure stops the business: login, payment, saving data. In my opinion a sensible order looks like this:

  1. Login, registration and user permissions.
  2. Payment and placing an order (checkout).
  3. Saving, editing and reading key data.
  4. Integrations with external systems.
  5. Business calculations: prices, discounts, taxes.

And what can wait? Screens that change every week at the MVP stage, the visual layer itself and one-off features. It is a waste of time. The scope of testing should grow together with the product, which is easy to see when you look through the stages of building a web application from the first version to scale.

When the tests run: tests in CI/CD

In a properly set up project the tests start on their own with every change in the repository, in the CI pipeline, before the code reaches the server. CI, or continuous integration, is an automated process: the developer pushes the code, and it builds the application and runs the tests. A red result blocks the deployment. So the bug stops with the developer, not with the customer. Usually the fast unit tests go first, and E2E runs on the test environment just before the release to production. And when working in sprints, typical of agile IT project management, full regression runs after every iteration.

Automated tests in the contract and the quote: what to ask the vendor

The contract should say plainly: which types of tests are created, which paths they cover, where they run and who maintains them after acceptance. Before signing, ask the software house these questions:

  • Which tests are included in the quote?
  • Which paths will get E2E tests?
  • Do the tests run in CI and block the deployment on failure?
  • Will I receive the test code and access to the results?
  • Who updates the tests when the application changes?
  • What does the test environment look like and where does its data come from?

Red flags? The answer “we test manually before deployment” with no automation at all. No tests in the repository. Tests priced as a paid extra with no defined scope. In practice it is best to discuss the scope of testing in the very first conversation about the project, whether it is about custom software development or applications built on AI.

Automated tests for a web application should be a clause in the contract, not a verbal promise. The minimum is short: unit tests for business logic, end-to-end tests for critical paths and all of it run in CI with every change. With such a clause it is easier to compare quotes, accept the project and develop it with peace of mind.

Frequently asked questions

Does a small application or an MVP need automated tests?

Yes. At least for login, payment and saving data, because their failure hits users right away. The rest can be covered with tests later, once the product stabilizes. Such a modest set protects the most important paths without a large upfront cost.

How do end-to-end tests differ from unit tests?

E2E tests check the whole user path in the browser, unit tests a single function in isolation. The former show that the process works as a whole. The latter quickly point to which part of the logic failed. You need both types, there is no point in choosing.

Who maintains the tests after the application is handed over?

It depends on the contract, so it is better to spell it out there. A good clause: the tests are part of the code handed over to the client and are updated with every change as part of support. This way they do not lose their value after the first fixes.

Book a free consultation

Provide your phone number or schedule a meeting