Is there recommended approach/setup for testing of...
# apollo-kotlin
j
Is there recommended approach/setup for testing offline/caching behaviour locally?
m
Something like UI tests including offline mode?
Can you even turn Airplane mode on from espresso tests? I read about that some time ago and it was not trivial
j
could we do something for example with
TestNetworkTransport
we'd want query to succeed initially so data in cache.....and then somehow "disable" network and verify we're getting data from cache then
m
I would do a OkHttp interceptor that is instrumentable and that can throw when "asked"
Another option would be to use the new NetworkMonitor and
failFastIfOffline
(but that's probably a bit more intrusive if you're not using it already)
j
m
Not sure I follow, I guess yes?
j
was just in case maybe with that config it wouldn't actually make network reqeust
m
The reasonning is that your OkHttp interceptor can trigger a "no route to host" exception just like OkHttp would normally do
So as far as ApolloClient is concerned, the production code and test code is the same
👍 1
j
thanks, will take a look at those
👍 1