How to mock API services in modules

Posted it in “Ask” already but I think it is more discussion than a question:

Is there any approach to mock API services in module test? There is a trivial guide to mocks but in modules API services are resolved not with annotations but with Context.getService(). And the Context is static so that no way to mock it with mockito.

I guess if module service have some separated method to resolve API services or delegate to them it should work. But I see not many tests with mocks in modules. Why so? May be it is not pragmatic or some other reason not to use mocks?

1 Like

@alexgg just seen this while searching. Am sure you got the answer. Do you wanna share it?

1 Like