Analyzing the challenges
In the previous chapters, we’ve been talking about adding new features while starting from the unit tests end (testing first). We relied on having a new functionality or modifying an existing functionality that is already covered by existing unit tests. This is not the case for brownfields as, when trying to apply TDD, you will face some of these challenges:
- Dependency injection support: Some legacy frameworks do not natively support DI, which is necessary for unit tests.
- Code modification challenges: Changes to code that are not covered by tests (of any type) can introduce new bugs.
- Time and effort challenges: Introducing the ability to unit test the code requires time and effort.
Let’s go through each challenge in detail, so you can consider them when the time comes.
Dependency injection support
In this book, before learning about unit testing or TDD, we had to introduce DI. DI is what allows you to separate your...