Testing with implicit dependency injection

Testing with implicit dependency injection is similar to testing with the cake design pattern. We can have a new object that creates mocks of the services and then makes them available to the test classes. When we want to use a concrete implementation of a service, we can just override it. We could also pass a dependency explicitly here.

Get Scala Design Patterns - Second Edition 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.