Test-Driven Development

Learn when to add new tests and get familiar with test-driven development.

Overview

When to add new tests? At which stage of the project and development cycle? The standard approach assumes that new tests should be introduced after finding a defect.

Each new production defect highlights the lack of existing tests, so we need to add one to verify that the fault is solved and will not occur again.

Another case is when we may need to add new tests right before we start to refactor our code. Covering our code with tests, we freeze its behavior with all its current use cases and guarantee that everything works before refactoring.

It’s especially applicable when we’re dealing with legacy code. In this case, writing tests makes sure that we understand how current components of the existing codebase work.

Get hands-on with 1200+ tech skills courses.