I'm developing an Android app and I'm wondering how to unit test an Activity or a Service using GoogleApiClient.
For instance, how to test an Activity or Service in the case GooglePlayService is available and in the case it is unavailable ? I was thinking about using Mockito but since GoogleApiClient is instantiated from inside the Activity, there is no way to mock it (AFAIK).
public class MyService extends Service {
...
private GoogleApiClient googleApiClient;
...
@Override
public void onCreate() {
...
googleApiClient = new GoogleApiClient.Builder(this) ... .build();
...
}
...
private void doSomething() {
if(googleApiClient.isConnected) {
...
}
}
Further more, I've read that mocking a third party library shouldn’t be done because my test suite won't fail if the library is updated but how can I do otherwise ?
PS: I'm sure this question has been asked before but I couldn't find the good keywords :/