Frage

just wanted to mock the OkHttpClient for testing purposes with Mockito. Sadly OkHttpClient is a final class which isn't supported by Mockito. Is there any other possibility to do the mocking, what do you guys do in there cicrumstaces?

Best

War es hilfreich?

Lösung

The HttpURLConnection API that OkHttp 1.x uses doesn't really lend itself to mocking. We're working on a new API for OkHttp 2 that will fit this use case better.

In the interim you may want to look at OkHttp's MockWebServer, which uses a real, in-process HTTP server.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top