Reputation: 1238
I haven't done any testing in Android, so please bear with me if this seems a stupid question.
I'm developing an app which makes a lot of network calls from a restful API service. To make the network calls, I'm using Retrofit2
and RxJava
.
What would be the best practice/framework to just test if these calls are working? I've started to read the Google Codelab for testing which uses Junit4
and Mockito
, but I don't want to do any clicking in the UI to start a test currently, just checking for different API versions which calls are supported or not.
Upvotes: 1
Views: 1590
Reputation: 13450
Here some steps for you that I am using:
Mockito.when()
)TestSubscriber
to test a method e.g. Observable<Location> getLocationFromApi()
.observeOn(mainThread())
). If inevitable use awaitTerminalEvents
in TestSubscriber. If there is no terminal even rethink your testGeneral tips:
Upvotes: 4