DEV Community

Cover image for How to Turn Undocumented Legacy Software Into a Testable System
Mike Ralduxin for DeviQA

Posted on

How to Turn Undocumented Legacy Software Into a Testable System

Here's what you actually inherit with a legacy product: software that's been in production for decades, a checklist where a test suite should be, and not one person who can state a business rule without opening the running system to check.

I've been dropped into that situation more than once. The two reflexes everyone reaches for — "write proper documentation first" and "automate regression first" — both fail, and for the same reason: you can't document or automate what nobody can specify.

The sequence that works is different: recover the requirements, confirm them with owners, record them as test cases that double as documentation, and only then automate — in risk order. On The Mortgage Office, a loan management platform, that four-phase program took regression from 2 days of manual work to 3 hours — but automation was phase three, not phase one.

Let me walk through the order of operations, because the order is the whole point.

The specification moved; it didn't vanish

The specification for a legacy system was never lost. It was redistributed — into production behavior, the defect archive, support tickets, and the heads of surviving engineers.

That reframe matters because it changes the job. You're not authoring requirements from scratch; you're retrieving them from four sources that still exist:

  • Production behavior. Whatever the system does today is the de facto contract. Users have built workflows on it, including on the bugs.
  • The defect archive. Every ticket ever filed is a requirement someone cared enough to write down. More on this below — it's the highest-yield source.
  • Support teams. They know which behaviors users scream about, which is a priority signal no document gives you.
  • Surviving engineers and product people. Fragmented, biased, and leaving the company one by one — but still the only source that can explain intent.

This is also why the cost of doing nothing is so high. In a field study of 79 professional developers across 3,244 working hours, Xia, Bao, Lo, Xing, Hassan and Li (IEEE TSE) measured that developers spend roughly 58% of their time on program comprehension. On an undocumented system, every engineer re-derives the spec from the code, every time, forever. Requirements recovery is paying that cost once and writing down the answer.

One rule I enforce from day one: a bug users depend on is a feature until someone with authority decides otherwise. Record the decision either way. On The Mortgage Office, phase one explicitly targeted documentation gaps and knowledge silos — reverse-engineering requirements with product managers, developers, and support — before anyone touched a framework.

The honest caveat: recovered requirements are descriptive, not authoritative. They tell you what the system does, not what it should do. Keep those labels separate in your artifacts.

Reverse-engineer requirements before you write a single test case

The core method, compressed: work one feature area at a time, pin current behavior with tests, write acceptance criteria for what's already shipping, and get a named owner to confirm each rule.

Working system-wide is the classic failure mode. A big-bang documentation project produces a wiki nobody trusts and stalls the moment priorities shift. Per feature area, you ship something usable — recovered rules plus the cases that check them — every few weeks.

Within a feature area:

  1. Pin behavior where code is reachable. Characterization tests (Feathers' term) or approval/golden-master tests: feed the system inputs, record what comes out, assert it stays that way. You're not asserting correctness — you're asserting stability.
  2. Record end-to-end flows where it isn't. For a UI-heavy module with no seams, a scripted manual flow with expected results is a legitimate characterization artifact. Automate it later, once it's confirmed.
  3. Write acceptance criteria for shipped behavior. Given/When/Then against the running system, not against anyone's memory.
  4. Confirm each rule with a named owner. A rule nobody confirmed is a guess wearing a test case's clothes.

A characterization test is honest about what it knows:

// CHARACTERIZATION: pins current prod behavior as of 2026-08.

// Late fee rounds HALF_UP to cents — owner unconfirmed, see LGCY-214.

test('late fee on a $1,033.33 balance at 5% is $51.67', () => {

expect(calcLateFee(103333, 0.05)).toBe(5167);

});

That comment convention is load-bearing. When confirmation stalls because no owner exists — and it will — timebox the search and mark the rule unconfirmed in the test, then move on. Never block the pipeline on organizational archaeology.

Does this produce real volume? On Catalyst, a Therapy Brands product with no detailed specifications, two QA engineers turned recovered behavior into 60 user stories with acceptance criteria and 150 Confluence pages, then roughly 1,000 test cases in Azure DevOps. The Mortgage Office work produced 10+ detailed documents for major features the same way. Neither started by writing test cases; both started by writing down what the system does.

The defect archive is your highest-yield source

If you only have time to mine one source, mine the bug tracker. Every historical defect is a requirement someone cared about, plus a datapoint on where the system actually breaks.

There's a reason this source is so rich: it's where the pain already got written down. In the 2024 Stack Overflow survey, 62.4% of professional developers named the amount of technical debt as a frustration at work — the top complaint. Your tracker is that frustration, itemized and timestamped, for your specific product.

The mining process I run:

  • Retest old issues. Sort every historical defect into three buckets: still reproduces (live defect), fixed (candidate regression case), or "works as intended now" (accepted behavior — document it as such).
  • Cluster by module. Defect density per feature area is your risk map, and it's built from evidence instead of opinions.
  • Convert confirmed clusters into regression cases. The modules with the ugliest history get cases first.

On BiznessApps, the team retested all legacy issues and reorganized a messy Jira — cleaning outdated entries, adding a bug report template — before scaling up documentation. That groundwork fed a suite of 5,000+ test cases covering more than 90% of the application, with 1,700+ issues and 300+ blockers reported along the way. The tracker cleanup wasn't housekeeping; it was requirements extraction.

Two limits, so you don't over-trust the archive:

  • It skews toward what users bothered to report. Silent areas of the product stay invisible, and silence is not evidence of health.
  • A bug that no longer reproduces may be fixed — or dormant, waiting on a data condition you didn't recreate. Treat "can't repro" as a bucket, not a verdict.

Make the suite the documentation

Prose decays silently; test cases decay loudly — they fail. That asymmetry is why the deliverable of requirements recovery should be a test suite, not a document set.

A Confluence page that drifted from reality looks exactly like one that didn't. A test case that drifted goes red in CI and demands a decision. If you want recovered knowledge to stay recovered, store it in the artifact that complains when it rots.

This isn't just my preference. DORA's research on documentation quality found that quality documentation amplified the performance impact of every technical practice they studied — and a traceable suite is documentation that runs.

What makes a suite navigable as documentation:

  • One repository, not scattered wikis. On The Mortgage Office, centralized repositories and testing standards came before automation, deliberately.
  • Traceability: feature → test case → automated script → defect. For Renhead we wired TestRail to the Cypress suite so a failing script points back to a case, and the case points back to a feature and its defect history.
  • Standards defined before volume accumulates. NEXSYS-ONE fixed inadequate test documentation alongside refined task descriptions and mandatory attachments in bug reports — the format rules landed before the 1,000+ cases did.
  • Coverage tracked per feature, not globally. A global number hides that billing is at 90% and reporting is at 10%.

Be honest about two things. First, a suite documents behavior, not intent or architecture — you still need a thin layer of prose for "why." Second, the cost: on Catalyst, that corpus of stories, pages, and ~1,000 cases came from two QA engineers across a five-year engagement. This is a multi-year practice, not a quarter's project.

Automate last, and in risk order

Automate only what you now understand and can assert against. Automation earlier than that just executes your ignorance faster.

This is the assumption I most want to kill — that automating regression is step one. In every engagement I've cited, automation came third or fourth, after recovery and documentation. And the industry numbers suggest most automation isn't carrying the load people assume: in the State of Testing 2025 report, only 20% of teams said automation had replaced 75% or more of their previously manual effort, though the share reporting no automation impact at all fell from 26% in 2023 to 14% in 2025.

There's a second assumption to kill: that whatever automation you inherited is an asset. Renhead's existing suite was outdated and unmaintainable — Selenium/Ruby, eventually replaced with Cypress. SoftNAS came with an improperly configured automated testing structure that had to be rebuilt. Undocumented automation is legacy code too, and it gets the same treatment: characterize it, salvage what's confirmed, delete the rest.

The sequencing that's worked, in risk order:

  1. Smoke first, then regression, then breadth. A thin suite over recovered critical paths, trusted on every build, beats a broad suite nobody believes.
  2. API-level before UI — even when the API is undocumented. On Renhead, API testing was integrated with no API documentation at all; the recovery method applies to interfaces, not just features.
  3. Generate test data through APIs, not UI clicking. The Mortgage Office team built API-driven test data population across 5 data patterns; NEXSYS-ONE did the same for test independence.
  4. Parallelize once the suite is trusted. NEXSYS-ONE runs 1,300 scripts across 15 threads; Renhead runs 4,000+ web tests across 5 threads. Parallelizing a flaky suite just distributes the noise.

The outcomes, each attributed to its full program — automation, CI, and process changed together, so I won't pretend to isolate one variable:

  • The Mortgage Office: regression 2 days → 3 hours, smoke 1 hour → 20 minutes, 100+ automation scenarios, 10 load scenarios in CI.
  • Renhead: regression from over 12 hours to 4, with smoke at 1.5 hours and 3,000+ bugs reported since 2014.
  • NEXSYS-ONE: automated regression in 1.5 hours, with 70% of blocker/critical/major bugs caught during development rather than after release.
  • SoftNAS: a low-level API suite built from scratch, 1,000+ scripts, 45% faster delivery of test results, and 25% fewer issues spotted after deployment.

Where this stops paying

Full coverage is not the target, and chasing it is where this method tips into waste.

The teams above stopped well short of 100% on purpose: The Mortgage Office reports coverage over 60%, up from an estimated 15%; NEXSYS-ONE sits at 75%; SoftNAS at 80%. Each figure uses its own denominator, so don't compare them — the shared signal is that every team drew a line where marginal recovery stopped being worth marginal cost.

A few more boundaries worth respecting:

  • Recovery cost scales with surviving stakeholders, not lines of code. A small system with zero owners can cost more to recover than a huge one with a live product team.
  • Characterization tests freeze bugs deliberately. That's a decision with a name attached, not an accident. Revisit the frozen ones on a schedule.
  • A component being replaced in six months may not deserve recovery. Pin its critical outputs with a handful of approval tests and spend your effort where the code will still exist next year.

And the objection I hear every time: "we're under release pressure, we need automation on day one." The answer isn't a full suite on day one — it's a thin smoke suite over the critical paths you've recovered so far, growing as recovery proceeds. That's automation in week one, scoped to what you actually know.

The whole method fits in one checklist:

  1. Recover requirements per feature area — from production behavior, the defect archive, support, and surviving engineers.
  2. Confirm each rule with a named owner; timebox and mark the unconfirmed ones.
  3. Record everything as test cases in one repository, with feature → case → script → defect traceability.
  4. Automate smoke and regression in risk order; treat inherited automation as legacy until proven otherwise.
  5. Measure coverage per feature, not globally, and decide where to stop.

Reach for this when you own a long-lived product that has to keep shipping. Skip it for code that's scheduled for deletion. And go in with the honest expectation: you'll end up with a system you can change safely — not one you fully understand. The cases above took years, not sprints, and that's what the work actually costs.

Top comments (0)