How to Test a Migrated Legacy System: Proving the New Code Behaves Like the Old

How to Test a Migrated Legacy System: Proving the New Code Behaves Like the Old

What "the same behavior" actually means

A migrated system passes testing when it produces the same results as the original for the same inputs, including the odd ones. That sounds obvious, but it is harder than it looks. The old system is usually the only complete specification you have. The original developers may be gone, the documentation is incomplete, and the business rules live in the code itself.

So the question is not whether the new screens load or the new services start. The question is whether a payment, a policy renewal or a ledger entry comes out exactly as it did before. Testing a migrated system means treating the legacy system as the reference and proving the new one matches it, case by case.

Run both systems side by side

A parallel run feeds the same real inputs to the old and new systems and compares what each produces. It is the most direct way to validate business logic after a migration, because it tests against what the business actually does, not what someone remembers it doing.

A few practical points make it work:

  • Decide up front what you compare: output records, calculated fields, generated files, audit entries. Compare the outputs that matter to the business, not every byte.
  • Run both systems on the same input at the same point in time, so date-dependent logic does not create false differences.
  • Log every mismatch with the input that caused it. A mismatch is either a defect in the new code or a rule nobody knew the old system had.
  • Keep the old system as the source of truth until the mismatch list is understood, not just short.

Parallel runs are slow and expensive to keep going, so use them where the risk is highest, such as payment calculation or policy pricing, and use targeted tests for the rest.

Build test data from production behavior

Hand-written test cases cover what people thought of. Production data covers what actually happens. Sample real transactions, with sensitive fields masked, and replay them through both systems.

Pick the sample deliberately. Ordinary cases will pass easily, so make sure the set also includes:

  • Edge values such as zero amounts, maximum field lengths and negative adjustments
  • Records that hit rarely used paths, like month-end, year-end or correction flows
  • Old records with unusual formats left over from earlier versions of the system

If you are unsure which paths are rarely used, finding unused code in the legacy system before you migrate tells you what you can leave out of the test scope and what still runs.

Turn recovered business rules into test cases

The strongest approach is to check business rules one at a time. That requires a list of the rules first. If you have recovered them from the source code, each one becomes a test case almost directly. Our guide on how to extract business rules from COBOL code before you migrate covers that recovery step.

Take a simple rule: the net payment equals the payment amount minus the fee. Recovered from the source, it is linked to the exact lines that implement it. Turning it into tests looks like this:

  1. Write down the rule in plain language, with a pointer to the source lines it came from.
  2. List the inputs that exercise it: a normal amount, a zero fee, a fee larger than the amount.
  3. Run each input through the old system and record the result as the expected value.
  4. Run the same inputs through the new system and compare.

Because every rule traces back to its source, a failing test points you to the original logic you are trying to match. It also gives auditors something concrete: a rule, its source evidence and a passing test. A platform like Replai that maps rules, workflows and dependencies from your code gives you this list instead of having to build it by hand from reading programs, though the testing method works with any rule inventory.

Do not forget what the rules touch

A rule can pass its own test and still break something downstream. In the payment example, the net amount also feeds a ledger entry and an audit record. If the new system calculates the right number but writes the ledger differently, the parity test on the rule alone will miss it.

Use change impact analysis and data lineage to list what each rule reads and writes, then add checks for those outputs. For banks and insurers, this is also where the risks described in our piece on legacy modernization risks for financial institutions tend to show up, so give those flows extra attention.

Decide what counts as done

Agree on exit criteria before testing starts. A reasonable standard is that every recovered rule has a passing test, every parallel-run mismatch is either fixed or explained and accepted by the business, and the high-risk flows have run on real data. Differences the business chooses to keep, such as a fixed rounding bug, should be written down as deliberate decisions, not left as silent changes.

Frequently asked questions

How do you test a migrated system?

Treat the legacy system as the reference and prove the new one matches it. Run both on the same inputs in a parallel run, replay masked production data through each, and check recovered business rules one by one.

What is parallel run testing in a migration?

It means feeding the same real inputs to the old and new systems and comparing their outputs. Each mismatch is either a defect in the new code or an undocumented rule in the old one.

How do you validate business logic after migration?

List the business rules recovered from the source code, write test inputs for each, record the old system's results as expected values, and compare them against the new system's results.

Where should test data come from?

Use masked samples of real production transactions, and make sure the sample includes edge values, rarely used paths such as month-end flows, and unusual older records.

Is a passing rule test enough?

No. A rule can calculate correctly and still write the wrong ledger or audit record downstream, so add checks for everything the rule reads and writes.

When is a migrated system ready to go live?

When every recovered rule has a passing test, each parallel-run mismatch is fixed or accepted by the business, and high-risk flows have run on real data.