TDD: Can I boot when expanding an existing large application?

Martin's chapter on TDD's Clean Code caught my fancy.

But.
These days I am basically expanding or fixing large existing applications.
TDD, on the other hand, seems to work only for writing from scratch.

Speaking of these great existing applications:
1. They were not imposed by TDD (of course).
2. I cannot rewrite them. 3. Writing comprehensive tests of the TDD-style for them is out of the question in the timeframe.

I have not seen mention of TDD "bootstrap" in a large monolith application.

The problem is that most classes of these applications, in principle, work only inside the application.
They are not separable. They are not common. Just to rekindle them, you need at least half of the entire application. Everything is connected with everything. So where is the boot file?

Or is there an alternative technique with TDD results that will work to extend existing applications that have not been developed with TDD?

+4
source share
3 answers

A bootstrap is to isolate the area in which you work and add tests for the behavior you want to keep and the behavior you want to add. The hard part, of course, makes it possible, since untested code tends to get confused together in ways that make it difficult to isolate a code area to make it verifiable.

Buy Effectively work with Legacy Code , which contains many recommendations on how exactly you do.

You can also see the answers to this related question. Adding unit tests to legacy code .

+3
source

Start small. Take a section of code that you can intelligently extract and make into the test class and do so. If an application is riddled with many hard dependencies and terrifying spaghetti logic that you cannot reorganize without fear of breaking something, start by creating a series of integration tests so that you can confirm the correct behavior before you start messing with it.

+2
source

Your existing application sounds as if it suffers from tight communications and a large amount of technical debt. In such cases, you can spend a lot of time trying to write comprehensive unit tests, where time can be better spent on conducting major refactoring, in particular, on promoting free communication.

In other cases, investing time and effort in unit testing using Mocking frameworks can be useful because it helps to separate the application for testing purposes, which allows you to test individual components. Dependency injection techniques can be used in conjunction with bullying to help do this as well.

0
source

All Articles