3 ms·
This article is extreme, in the case of Java (mockito), using mocks is a great way to infer the path the logic takes. If anything mocking is useful for verifyi
by tomaytotomato 3y ago
This article is extreme, in the case of Java (mockito), using mocks is a great way to infer the path the logic takes.
If anything mocking is useful for verifying that something is called whether that be a service or a repository method.
Equally mocking things like mappers is overkill, a nice balance is to inject some mocks and some "real" instances of dependencies into the class that is under test.
The added benefit is that you are testing the dependencies (if the mapper for example) are working.
- regularfry 3y agoVerifying that something is called is the canonical use case for a mock. If you're using a mock and it's not doing verification, it's not a mock. It's something else.