Dependency Injection

Dependency injection1 has grown from a hand-spun and somewhat obscure application assembly approach to a mainstream and widespread approach. Implemented in the Spring framework (Listing 12-1) and the EJB 3.0 (Listing 12-2) specifications in the Java world, Windsor container in .NET,2 and others in many languages, use of dependency injection and inversion of control frameworks has become commonplace, if not always well understood. The prevalence of the frameworks and the principles behind them yields a high likelihood that we can use this pattern for our testing.

1. Also known as Inversion of Control. See www.martinfowler.com/articles/injection.html for an early unifying treatment on the topic.

2. http://docs.castleproject.org/Windsor.MainPage.ashx ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.