Chapter 11 Simplifying Design with Dependency Injection

In Dependency Injection, we saw how Cucumber uses dependency injection (DI) to share an instance of KnowsTheDomain between our step definitions, but we really only scratched the surface. Now it’s time to dig a little bit deeper.

In this chapter we’ll discuss how DI can help improve the design of your test code and the various DI containers that are integrated with Cucumber. Then we’ll dive in and refactor our ATM example to use DI more effectively, showing you how to do it with four of the popular DI containers.

Get The Cucumber for Java Book 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.