Alternate Injection Techniques

So far you’ve seen a few creative techniques to support the ability to test otherwise-difficult-to-reach code. We used constructor injection, setter injection, and a member variable spy. The techniques you learned about in Chapter 5, Test Doubles, such as Override Factory Method or Introduce via Template Parameter, can apply here. If absolutely necessary, you can look at even more creative approaches, such as using the preprocessor to redefine bits of code.

Avoid falling into the hammer-nail trap of sticking to one dependency-breaking technique. Working Effectively with Legacy Code [Fea04] introduces a couple dozen useful patterns. Your job is to familiarize yourself with all of them so that you can choose the most appropriate to your situation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.104.183