How to unit test Actions using google-api-client

I am developing an Android application and I am wondering how to unit test perform an action or service using GoogleApiClient.

For example, how to check an action or service if GooglePlayService is available and if it is not available? I was thinking about using Mockito, but since the GoogleApiClient was created from within 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) {
        ...
    }
}

Also, I read that bullying a third-party library should not be done, because my test suite does not crash if the library is updated, but how can I do otherwise?

PS: I'm sure this question was asked earlier, but I could not find good keywords: /

+4
1

. ...

(...), GoogleApiClient Activity

, , . factory ( ), ( ).

, , , , , ?

. , , , , . unit test ( ), unit.

+1

Source: https://habr.com/ru/post/1568205/


All Articles