Every modernization project eventually holds a meeting about requirements. The business analysts bring the original specification. The developers bring the code. And within an hour it's clear that neither describes what the system actually does today, because fifteen years of fixes, patches, and urgent changes have been made to the code and never written down anywhere else.

That gap is the most underestimated risk in modernization. The new system gets built to the specification everyone agrees on, it passes its tests, and it goes live. Then the complaints start: invoices that are a cent off, a customer category that's handled differently, a report that used to exclude a type of transaction and now doesn't. Each one is a requirement nobody knew they had.

The answer isn't a better requirements document. It's a set of tests that capture what the current system does — before anyone changes it.

Why legacy behavior is the real specification

Over time, a working system accumulates decisions. Someone added a special case for a large customer. Someone changed the rounding method to match what the tax authority expected. Someone fixed a bug in a way that other systems then came to rely on. None of these decisions were made by the people planning the modernization, and most of the people who made them are no longer around.

Some of this behavior is valuable, some of it is accidental, and some of it is wrong. But the business has adapted to all of it. Downstream systems, reconciliation processes, and customer expectations are built on what the system does, not on what it was supposed to do. Change the behavior without knowing it, and something somewhere breaks.

A legacy system is the only complete record of its own requirements. Read that record before you replace it.

Characterization tests: recording what is, not what should be

Characterization tests are a simple idea. Instead of testing that the system does what it should, you record what it does: given these inputs, it produces these outputs. You don't judge whether the outputs are right. You capture them, so that any change in behavior becomes visible.

For most business systems, the practical approach is to test at the edges rather than inside the code. Legacy code is often hard to unit test, but its inputs and outputs — files, messages, database records, reports — are usually accessible.

  • Capture real production traffic. Record a representative sample of real inputs and the outputs the current system produced, with sensitive data masked. This is the richest source of test cases you have, because it reflects what actually happens rather than what someone thought to test.
  • Include the calendar. Month-end, quarter-end, year-end, leap years, and public holidays often trigger different code paths. A month of captured traffic that doesn't include a month-end run is missing the cases most likely to fail.
  • Compare outputs automatically. Build a comparison that runs the same inputs through the old and new versions and reports every difference. Decide up front which differences are acceptable — a timestamp format, field order — and flag everything else.
  • Mine the incident history. Past production incidents and their fixes point straight at the behavior that matters most. Each one should become a test case.

Triage every difference

When the comparison finds a difference, someone has to decide what it means. In practice, every difference falls into one of three groups.

  • Preserve it. The old behavior is correct, or other systems depend on it. The new system needs to match, even if the rule looks odd.
  • Fix it deliberately. The old behavior is wrong, and the business agrees to change it. The change gets communicated to everyone affected — downstream systems, finance, customers if necessary — before go-live rather than after.
  • Retire it. The behavior served a purpose that no longer exists: a customer who left, a product that was discontinued. It can be dropped, and dropping it simplifies the new system.

Who makes these decisions matters. They're business decisions, not technical ones, and they need a named business owner with the authority to make them. Engineers left to decide alone will either preserve everything, which defeats the point of modernizing, or fix things nobody asked them to fix.

Keep the tests after go-live

The comparison harness is valuable long after the first release. During a phased migration, it shows that each piece moved across still matches. During a parallel run, it does the comparison that people would otherwise do by hand. And after the old system is switched off, the captured cases become the regression suite for the new one — the first time in years the business has had a complete record of what its system is meant to do.

A short worked example

A utility company was rewriting a billing engine that calculated around 900,000 bills a month. The specification was a 300-page document last updated in 2014. Before any new code was written, the team captured three months of production inputs and outputs, including a quarter-end and a tariff change.

Running the first version of the new engine against that set produced differences on about 4% of bills. Triage traced them to 37 distinct behaviors that weren't in the specification. Twenty-two were preserved, including a rounding rule the regulator had required in 2016. Nine were fixed deliberately, with notice to customers. Six were retired, including a discount scheme that had closed in 2018 and still had two hundred active accounts nobody had migrated.

Go-live was uneventful. Billing complaints in the first quarter were lower than in the same quarter the previous year — which, for a billing replacement, is close to unheard of.

The honest takeaway

Capturing the behavior of a legacy system takes weeks, and it uncovers decisions the business would rather not have to make. But those decisions are coming either way. Make them in a triage meeting, with time to think, rather than in an incident review after the first billing run.

Test what the system does before you change what it does.