How @InjectMocks works with Mockito
9th Aug 2021 by Aneesh Mistry

How to use @InjectMocks

@InjectMocks will allow you to inject other spies and mocks into a class that requires services when it is being tested. The annotation will scan the class under test and automatically inject all available mocks and spies from within the test class. No more NullPointerExceptions when an unknown service is called!

YouTube video link


Share this post