Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent proxy for testing server responses offline in Android

I have a data-driven Android app scaffold. Adding tests, aiming for 100% coverage. Using OkHttp.

How do I transparently intercept calls to my server with mock responses?

Want this for—end-to-end as well as—unit tests. E.g.: setting build-type to MockServer should load an app that will show mock responses in the emulator.

like image 840
A T Avatar asked Oct 14 '16 01:10

A T


1 Answers

Did you look into okhttp mockwebserver?

I use it for mocking responses and verifying/showing requests.

If you want to use this with a build type, you can generate an Android resource or java constant in gradle and then start the server and set the path accordingly.

like image 192
Ole Avatar answered Nov 18 '22 16:11

Ole