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 . 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.

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.

Starting from appium 2.0, we have a light weight plugin to make API mocking possible for Native/Hybrid android apps using Do give it a try and let us know if you face any issue.

The proxy does not run using appium-interceptor plugin