FREN

Let’s keep in touch

Social

Technologie· 10 min read

Automated testing on an existing application: where to start

Where to start automating tests on an existing application: critical journeys, characterization tests, the test pyramid, flaky tests and CI/CD.

On an existing application without tests, you start neither by aiming for a coverage rate nor by automating every screen: you first protect the few user journeys the business depends on, you pin down the behaviour of the code before changing it, then you require tests for all new or changed code. This guide gives the order of the steps, the types of tests to favour, how to handle flaky tests and where they fit in the pipeline.

It is written for technical leaders, CIOs and application owners who inherit code with few or no tests and want to evolve it without regressions. Automated testing is at the heart of our quality assurance and testing offer.

Why automate the tests of an existing application?

Automating the tests of an existing application means being able to change it without breaking what works. An application in production changes constantly: fixes, changes requested by the business, upgrades of the language or the framework. Without tests, each change is checked by hand, or not at all, and regressions are found by users.

Automated tests make this check fast and repeatable, on every change. They are also the precondition for reducing technical debt: you do not restructure, without a safety net, code that nobody fully knows any more. An upgrade, such as the one required by the end of fixes for Symfony 6.4, is when that safety net is missed most.

Where do you start with automated tests?

Automated tests on an existing application start with the journeys whose failure costs the most, not with the code that is easiest to test. For existing (brownfield) systems, the DORA research programme, run by Google Cloud, advises against trying to cover everything: write a small number of acceptance tests for high-value functions, then require unit and acceptance tests for all new or changed code. Coverage then grows at the pace of changes, where the risk lies.

  • List the critical journeys. With the business and support teams: what brings in revenue, what breaks often, what is subject to an obligation (invoicing, personal data).
  • Protect them with a few end-to-end or API tests. One or two per journey, checking the expected outcome rather than the details of the screen.
  • Run them on every change. A few reliable tests run automatically are worth more than a long manual campaign rarely repeated.
  • Require a test for every fix. A fixed defect gets the test that would have caught it: it will not come back silently.
  • Pin down behaviour before restructuring. Before touching an old module, characterization tests describe what it does today.

What is a characterization test?

A characterization test describes the actual behaviour of existing code, as it is today, not as it should be. Michael Feathers described the method in his book Working Effectively with Legacy Code (Pearson, 2004): before changing old code, you write tests that record what it produces, to make sure you do not change its behaviour unintentionally.

The method is simple: run the code with representative inputs, record the outputs (a page, a file, an API response), and the test then checks that they do not change. It is also called a “golden master”. Values that vary from one run to the next, such as a date or an identifier, must be masked. If the test reveals odd behaviour, you keep it as it is: fixing it will be a separate change, decided and tested.

Which types of tests, and in what proportions?

The right proportion follows the test pyramid: many small, fast unit tests, fewer integration or service tests, and very few end-to-end tests that go through the user interface. The model comes from Mike Cohn (Succeeding with Agile); Ham Vocke sums it up in “The Practical Test Pyramid”, published in 2018 on Martin Fowler’s website: the more high-level a test is, the fewer of them you need.

Type of testWhat it checksSpeed and maintenance
Unit testA function or a class, isolated from the restFast and cheap: write many of them
Integration or API testSeveral components together: database, service, HTTP callSlower: a reasonable number
End-to-end testA complete journey, through the interface, like a userSlow and fragile: reserved for critical journeys

The inverse shape, with many tests through the interface and few unit tests, has a name: the ice-cream cone. Ham Vocke points out that end-to-end tests are notoriously flaky, need a lot of maintenance and run slowly; he advises reducing them to a bare minimum and pushing each test as far down the pyramid as possible. On an existing application, however, the pyramid is often built from the top: end-to-end tests of the critical journeys come first, because the code is not yet split up for unit tests; unit tests follow, as fixes and restructuring go on.

What should you do with flaky tests?

A flaky test, one that sometimes fails without the code having changed, is taken out of the main suite and fixed quickly. Martin Fowler calls them infectious: when a few tests fail at random, the team gets used to ignoring failures, real ones included. He recommends putting them in quarantine, in a separate suite whose size or time limit is capped, then fixing them.

The causes are nearly always the same: tests that depend on one another, asynchronous processing awaited at the wrong moment, an unavailable remote service, the current time or date, resources not released. The DORA programme takes the same line: a small, trustworthy suite is better than a large one nobody trusts, and flaky tests are not to be tolerated.

Which data should tests use?

Each test prepares its own data and does not depend on what another test left behind: a shared test database, changed by one test and read by another, is a classic source of flakiness. Nor should this data be a copy of production. Our article on test data and the GDPR explains how to test without copying personal data.

Which testing tools for which technology?

The testing tool depends first on the application’s language and framework: most common frameworks ship their own, already configured. For the technologies we come across most often:

TechnologyTesting toolsWhat the documentation provides
Symfony (PHP)PHPUnitUnit, integration and application (functional) tests, which send real or simulated HTTP requests
Laravel (PHP)Pest or PHPUnit, included out of the boxTwo folders, Feature and Unit; the documentation advises writing mostly feature tests
AngularVitest by default in new projects; Karma is still supportedTests run in a simulated browser (jsdom)
Flutterflutter_test, integration_testUnit, widget and integration tests
End-to-end web journeysPlaywright, SeleniumA driven browser that replays a journey; Playwright covers Chromium, WebKit and Firefox

Advice varies from one framework to another. Laravel’s documentation recommends writing mostly feature tests, which boot the application, because they give the most confidence in the system as a whole; Flutter’s aims for many unit and widget tests, plus enough integration tests to cover the important use cases. The common principle: keep slow, browser-driven tests for the journeys that justify them.

How do you plug tests into the CI/CD pipeline?

Automated tests only protect if they run on their own, on every change, in the continuous integration pipeline. The DORA programme advises starting small: a skeleton pipeline with a single unit test, a single acceptance test and an automated deployment script, which you then flesh out. It also gives an order of magnitude: a developer should know within ten minutes whether their change breaks something. Our CI/CD guide details the stages of a pipeline.

  • Fast tests first. Unit and integration tests on every change; end-to-end tests after deployment to staging.
  • A failure stops the chain. A change that breaks a test goes no further.
  • A red pipeline is fixed straight away. Before any new feature, otherwise the team gets used to ignoring it.
  • Developers write and own the tests. DORA lists keeping developers away from testing among the common pitfalls.

How do you measure progress on automated tests?

Progress is measured by the confidence the team places in its tests, not by the coverage rate alone. Martin Fowler puts it bluntly: code coverage is useful for finding untested parts of a codebase, but of little use as a statement of how good the tests are, and a figure close to 100% should rather raise suspicion. The DORA programme suggests more telling measures:

  • the share of defects found early, in the cheapest test phases, rather than in staging or production;
  • the time spent fixing test failures;
  • the share of failures that point to a real defect, not a flaky test;
  • whether all test suites run on every pipeline trigger;
  • the share of tests written by the developers themselves.

For an application under maintenance, these measures join those of corrective maintenance: fewer regressions in production mean fewer defects to fix in a hurry.

Frequently asked questions

What is a regression test?
A regression test checks that a change has not broken what already worked. Once automated, it runs on every code change and immediately flags a function that no longer behaves as before.
Can you add tests to an application that has none?
Yes. Start with a few end-to-end or API tests on the critical journeys, then add tests with every fix and every change. Before restructuring an old module, characterization tests pin down its current behaviour.
Should you aim for 100% code coverage?
No. Coverage helps find code that nothing tests, but it does not tell you whether the tests are good. A very high figure can hide tests written for the number rather than for the risk.
Do automated tests replace manual testing?
No. They take over repetitive checks, on every change. Exploratory testing, business acceptance and usability checks remain human.
Who should write automated tests?
First the developers who write the code, in the same change. A QA team can build end-to-end tests and lead the effort, but tests kept away from developers age badly.
How long should a test suite take?
The DORA programme aims for feedback in under ten minutes for the developer. Slow tests, such as end-to-end tests, can run later in the pipeline, after deployment to staging.

Automated tests: protect what the business depends on first

Automating the tests of an existing application requires neither rewriting everything nor reaching a coverage figure. You first protect the journeys the business depends on, pin down the behaviour of the code before touching it, run the tests on every change, and do not let a flaky test erode the team’s confidence.

The iones team sets up and maintains automated tests on existing applications, as part of its quality assurance and testing offer and when taking over a web application. To review the tests of your application, write to us.

Sources

  1. The Practical Test Pyramid, Ham Vocke – Ham Vocke, 26 February 2018
  2. Capabilities: Test automation, DORA – Updated 17 July 2025
  3. Eradicating Non-Determinism in Tests, Martin Fowler – 14 April 2011
  4. TestCoverage, Martin Fowler – 17 April 2012
  5. Working Effectively with Legacy Code, Michael Feathers – Pearson, 2004
  6. Characterization test, Wikipedia – Definition and golden master
  7. Testing, Symfony – Symfony 8.1 documentation
  8. Testing: Getting Started, Laravel – Laravel 13.x documentation
  9. Testing, Angular – Angular documentation
  10. Testing Flutter apps, Flutter – Flutter documentation
  11. Installation, Playwright – Playwright documentation

Start a project

Ready to take action?

Tell us what you need – we will get back to you quickly with a technical assessment and an action plan.

  • Reply within 48–72 hours
  • No-obligation conversation
  • NDA confidentiality