1

I am using Espresso framework for my android UI automation. I need to make an REST API call and get the response and use it for my assertions. Should I add any dependencies in gradle file / how to use ?

Thanks

Pinky
  • 71
  • 5
  • 1
    I'd argue making a live REST call as part of a UI test is too much for a unit test. The REST call and UI interaction should be tested in two separate stages - your UI test should only be concerned about handling success and failure states. This can be done by mocking the class you're using to make the REST call and returning successful or failed states. The testing of the REST service should be kept as a unit test for your REST adapter. – Michael Dodd Feb 01 '18 at 10:37
  • Likewise, you should never call a live REST API as part of a unit test. Too much potential for stuff to go wrong that's not directly related to your code, e.g. loss of network, REST API server going down. Network calls should always be tested using a mock web server. – Michael Dodd Feb 01 '18 at 10:40
  • I agree but in a case where certain actions can be performed only in web for which the the created data from web will be utilised in mobile app. In such a case, I need to perform that action by calling the API and then perform further actions interacting with mobile UI – Pinky Feb 01 '18 at 10:41
  • Like in Appium, we use simple JSON and rest. Is there any way to do in Espresso ? – Pinky Feb 01 '18 at 10:44
  • And this can't be done by providing an expected JSON example from the mock web server? – Michael Dodd Feb 01 '18 at 10:54
  • did you found a solution? – Gustavo Forero Carvajal Mar 05 '20 at 20:46

0 Answers0