Mocking API responses for Android automation

Hello All,
I am trying to mock the API responses so that I can cover over a range of test scenarios.
However i am seeing post over internet that what I am trying is impossible to achieve.
Have anyone you have managed to mock the responses? If so please let me the know the solution
It will be a BIG help… thanks in advance

What API calls are you trying to mock the responses to? If it’s your app, you’ll have to use a third-party proxy and set that up outside of appium.

Thanks got getting back. I am trying to mock the REST API calls in android.
Tried using okhttp3 mock webserver. The mockwebserver setup without any issues. However the calls doesn’t look like they are being intercepted. Tried setting up the end points in the app to point to local host which in android is 10.0.2.2 . That too doesn’t look like its working.
Running out of ideas. Do you have any suggestions like if there are other framework for mocking api responses for automation

Hi, Yes you can mock the API calls and check the details in mobile. Please find this youtube link for the step by step process. https://www.youtube.com/watch?v=HKfVAXMjw_8&feature=youtu.be

Thanks for the reply…
Having Charles proxy is great. However for a test suite to run faster I was looking down to cut the corners by mocking the response within the test suite itself using okhttp3 mock webserver for android. Do you have any suggestions?

Sorry, i haven’t done something like that before.

np. Appreciate for replying back.

Have you find the solution to your problem statement

Is there any solution to this ? Can we mock api responses in automation scripts ? Any pointers would be much appreciated.