A simple OKHttp client mock, using a programmable request interceptor MockInterceptor interceptor = new MockInterceptor(); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build();
Then in the tests: interceptor.addRule(new Rule.Builder() .get() .url("https://testserver/api/json") .respond("{succeed:true}", MEDIATYPE_JSON));
from The Android Arsenal
No comments:
Post a Comment