Mocking in In-App Purchase UI Tests — Mockito, Dagger2 and Espresso

1 · Hootsuite · Aug. 31, 2018, 9:37 p.m.
Testing In-App Purchase (IAP) flow is especially difficult — completing the flow produces side effects that are hard to reverse, e.g. upgrading a user or making a purchase, so it makes sense to mock these calls even in a UI test. In this article we will create Espresso UI Instrumented tests for Android that will proceed through the IAP, mocking the responses from Google Billing and our own user database.The stackAndroid Espresso Test FrameworkDagger 2 Dependency InjectionMockito 2The processCrea...