JavaScript Congress • Nov 24, 2021

How to TDD in legacy code

Gil Zilberfeld

Does your old codebase resist test-driven development? Discover how characterization tests and strategic pre-refactoring can safely untangle complex anti-patterns and bring TDD to legacy systems.

Pause
Mute Enter Fullscreen
#1 about 2 min

The basic concept of test-driven development

The standard red-green-refactor cycle provides a structured framework for code generation on greenfield projects.

#2 about 3 min

Challenges of applying test automation to legacy code

Complex dependencies and code resistance make traditional testing methodologies risky in existing codebases.

#3 about 2 min

The practical value of writing automated tests

Immediate feedback from automated test suites accelerates feature delivery and isolates implementation bugs.

#4 about 4 min

Adapting test-driven methodologies for existing systems

Adopting characterization assertions and pre-refactoring strategies bridges the gap between test-driven development and legacy systems.

#5 about 3 min

Analyzing a messy legacy calculator application

A poorly written calculator module with duplicated logic and incomplete functionality highlights the challenges of untested architecture.

#6 about 3 min

Writing characterization tests to document existing behavior

Mapping out current system capabilities with characterization tests safely documents expected behaviors before source modifications.

#7 about 7 min

Fixing software bugs using test-driven principles

Capturing a flaw via a failing assertion ensures only the minimal necessary patch is applied prior to cleanup.

#8 about 7 min

Pre-refactoring complex codebases before adding functionality

Flattening convoluted arrow structures with guard clauses and switch statements prepares legacy functions for new feature logic.

#9 about 4 min

Implementing new behavior and extracting helper methods

Writing targeted tests before feature patches allows raw implementation details to be safely extracted into abstract operations.

#10 about 6 min

Summary of testing steps for legacy systems

Characterization testing limits, localized patches, and continuous cleanliness practices reliably minimize legacy deployment risk.

#11 about 9 min

Testing guard clauses and behavior-driven development strategies

Edge case assertions, behavior-driven stories, and snapshot validation mechanisms offer proven solutions for inherently untestable modules.

Matching moments

2:02 min

Building test infrastructure for existing legacy projects

Alexandre Borges · WWC 2023

4:42 min

Identifying scenarios where strict test driven development limits agility

James Bender · LIVE

2:52 min

Navigating legacy projects lacking existing unit tests

Annelore Egger Annelore Egger · WWC 2025

8:22 min

Navigating legacy systems and unconventional software testing practices

Philipp-Alexander Blum · LIVE

4:00 min

Adopting test-driven design as a strategic development methodology

Mirjam Aulbach · WWC 2022

1:27 min

Understanding the fundamental test-driven development loop

Nadeen Hussein Nadeen Hussein · WWC 2024

Upcoming sessions on this topic

Open session

World Congress 2026 North America

Agents Can't Iterate Against Tests That Lie

Rocky Warren

Senior Staff Software Engineer at Clipboard

Rocky Warren
Open session

World Congress 2026 North America

Reinventing Testing Practices in the AI Era

Eric Deandrea

Java Champion & Senior Principal Software Engineer, IBM

Eric Deandrea
Open session

World Congress 2026 North America

One Repo, One Strategy: Scalable Full-Stack Testing in a Monorepo World

Bartosz Leczycki, Paweł Matynia

Bartosz Leczycki
Paweł Matynia
Open session

World Congress 2026 North America

From Legacy to Longevity – How a 17-Year-Old System stayed Modern

Alexander Arians

Empowering Engineers to drive innovation

Alexander Arians
Open session

World Congress 2026 North America

Testing React Backends Like a Pro: Mocking Databases with SQLite

David Morris

Solution Architect

David Morris
Open session

World Congress 2026 North America

There's no dark factory without better software verifiers

Dexter Horthy

Co-Founder, HumanLayer

Dexter Horthy