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 · World Congress 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 · World Congress 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 · World Congress 2022

1:27 min

Understanding the fundamental test-driven development loop

Nadeen Hussein Nadeen Hussein · World Congress 2024

Upcoming sessions on this topic

Open session

Teaching AI Coding Agents to Build It Right the First Time

  • Sajeetharan Sinnathurai

    Microsoft

    Principal Product Manager

Open session

From Profiler to Production: Measuring What Actually Matters in React & React Native

  • Andrei Tazetdinov

    Dynatrace

    React Native Developer

Open session

What I Got Wrong Shipping an MCP Server for Live Infrastructure

  • Pritesh Kiri

    Harness

    Developer Relations Engineer

Open session

How We Cut Our API's p99 Latency from Minutes to Under a Second

  • Deepak Agrawal

    Atlassian

    Principal Software Engineer

Open session

Beware of Strangers Bearing Code: Open Source Trust in the Agent Era

  • Vikram Vaswani

    Consultant

Open session

Beyond File Dumps: Context Engineering for Coding Agents

  • Animesh Dutta

    Arm

    Senior Software Engineer