I want to simulate the no network case when using RetroFit
and MockWebServer
.
Im currently testing using Espresso
and supplying the MockWebServer
s url to the RestAdapter
before I start my tests. This works great for mocking server responses and so on but I cant see a simple way to script the java.net.ConnectException
exception thrown when a device has no network. I can see the MockResponse allows throttling simulation and so on but not a custom exception.
I know I could go the root of mocking the actual web api interface used by retrofit
but I would like to use the same approach as my other tests if possible by using MockWebServer
.
I imagine I've just missed something simple :)
Thanks