Regression testing for legacy software: where to start when there are no tests

Regression testing for legacy software: where to start when there are no tests

In short: Regression testing for legacy software starts from the outside. First record how the system behaves today, for the five to ten processes that cost most when they break. Test through the screens or the interfaces, not through the old code. Automate those tests and run them before every change. Today’s behaviour is your specification, even where it’s odd.

Every company has one: the system that’s been producing the invoices for fifteen years. The developer who built it is gone, there’s hardly any documentation, and there are no tests at all. Every change gets tested by hand by the one colleague who knows how it works. So you change as little as possible, and when you have to, a pile of changes goes live at once. That makes every release scarier. Regression testing for legacy software breaks that cycle, and you don’t even need to understand the old code to do it.

Why is regression testing legacy software so hard?

Regression testing legacy software is hard because everything that normally makes testing easy is missing. Legacy software is old software that still does important work but is built on outdated technology. There’s no specification, so nobody knows for sure what the system is supposed to do. There are no tests, so you can’t see whether a change breaks something. The code wasn’t built to be tested: everything is tangled together, and you can’t check one piece on its own. And the knowledge sits in one or two heads. When that colleague retires or goes on holiday, the team grinds to a halt. The result is a vicious circle. Because changing things is scary, you rarely change anything. Because you rarely change anything, lots of changes go live together. And because lots go live together, things go wrong more often.

Where do you start when there isn’t a single test?

You start by recording what the system does now, not what it should do. A test like that is called a characterization test. It describes the current behaviour, so you notice when that behaviour changes. Whether the behaviour is right is a separate question. Here’s how to go about it.

  1. Pick the processes that matter. Five to ten processes where a failure costs most, or where most changes happen. Creating invoices, processing an order, a report for the regulator. Use risk-based testing to choose.
  2. Have the expert show you. Sit that one colleague next to a tester and let them walk through each process. Write down what happens, with which data, and what comes out.
  3. Record the output. Keep what the system produces: an invoice, a file, a screen, a message to another system. That’s your reference.
  4. Compare after every change. Run the same input again and compare the output with the reference. Every difference is a question: intended or not?
  5. Automate what’s stable. Start with the processes that change least. Those tests build trust fastest.

If you find behaviour that looks wrong, don’t quietly fix it in the test. Write it down and let someone decide. Sometimes another system or department relies on exactly that odd behaviour.

Do you need to understand the old code first?

No. You test the behaviour from the outside, through the screens, the interfaces or the files the system produces. That way you have tests before anyone touches the code. My advice is not to start with unit tests, small tests of single pieces of code. In legacy code you often can’t pull those pieces apart without changing the code. And changing the code without tests is exactly the risk.

There’s a trade-off. Tests through the screen are slower and break more easily than tests deeper in the system. For legacy software that’s a fine start, but not the end point. Once the team gets more grip on the code, add tests at the level of interfaces and single functions. That’s how you grow towards a healthy test automation pyramid, with most tests at the bottom and few at the top.

We saw this work at the Government Operations Centre. There were no regression tests on a platform that kept changing. Using use cases, exploratory testing and automated tests across browsers, we built a structured regression framework, with release advice after every test cycle. The result: consistent releases.

What if the system is going to be replaced?

That’s exactly when you need these tests. In a replacement or migration, you want to know whether the new system does the same as the old one. Your characterization tests are that check: the same input, then you compare the output of old and new. Many teams replace a legacy system piece by piece, which Martin Fowler calls the strangler fig pattern. Old and new then have to agree for a while, and you want that check to run automatically every night.

So build the test automation during the replacement, not after it. That way it guards the trial migrations and the switch itself, and then keeps running on the new system. Sorting out testing after go-live is too late: by then your users are the ones finding the differences.

What does this mean for your team?

For your team, it means the knowledge moves out of one head into a test suite anyone can run. Then you can change things more often and in smaller steps, and releases get less tense. The hard part is keeping it up. At clients we see that knowledge of the automation leaves as soon as the engineer who built it leaves. Then you have the same problem, just one layer up.

That ongoing work is what we handle with Test Automation as a Service, working alongside your team. For teams that still run their regression tests by hand, we cut that manual work by up to 70%. Your tests run every night, and we keep them reliable. You get a stable test suite your team can trust, one that doesn’t depend on a single person or add to your team’s workload. The suite is yours: documented and transferable.

A first step for this week: book an hour with the colleague who knows the old system best. Have them walk through the most important process and write down every step. That’s your first test.

Change your old system with confidence again, with tests that run every night.

See how TaaS worksTalk to our team

Frequently asked questions

What is a characterization test?

A test that records what a system does now, without judging whether that’s right. It shows you when the behaviour changes. The term comes from Michael Feathers, who wrote about it in his book on working with legacy code.

Can you test legacy software without documentation?

Yes. You use the current behaviour as the specification. Have someone who knows the system walk through the processes, and record the outputs as your reference.

How many tests do you need to start?

Fewer than you think. Five to ten well-chosen processes already give a lot of confidence. Then expand to the places where changes happen.

Which tool should you use for old systems?

It depends on how you can reach the system: through a web screen, a desktop application, files or interfaces. Pick the tool to fit the access you have, not the other way round.