I use Scalamock for unit testing my Java project. Project contains classes that use Java CDI style DI:
class Resource {
@Inject
private Service service;
.....
}
How can I inject mock as a Service instance? With Mockito I'm able to use @InjectMocks, but I definitely want to use Scalamock.
Currently ScalaMock does not support Mockito's @InjectMocks
equivalent.
In case of setter/constructor injection you can inject your mocks manually. In case of field injection you could access the private fields using reflection, but that would be very cumbersome.
Please create new ScalaMock feature request (https://github.com/paulbutcher/ScalaMock/issues) - if it gets upvoted we can implement it.