...

/

One Last Simplification: Introducing an Injection Tool

One Last Simplification: Introducing an Injection Tool

Learn to simplify tests using dependency injections.

Passing a mock to a target class using a constructor is one option. It requires a change to the interface and exposes a private detail to another class in the production code. Not a great deal, but we can do better by using a dependency injection (DI) tool like Spring DI and Google Guice.

Dependency injection in Mockito

Since we’re using Mockito, we’ll use its built-in DI capabilities. The DI power in Mockito isn’t as ...

Access this course and 1400+ top-rated courses and projects.