i'm trying to test Android app using Espresso FW and I stucked on the problem with doing async HTTP request.
How can i test the case that app (activity) is waiting for processing request and after the response is received is displayed next activity with result or error message?
I tried to find any solution how to do it in the Espresso with testing against the data from the test server, but without luck.
Many thanks for any advice, example or link.
The most used assertion is the matches() assertion. It uses a ViewMatcher object to assert the state of the currently selected view. onView(...). check(matches(withText("Hello!")))
I struggled with this for a few days. If your app is using retrofit to handle HTTP requests, you can add this one line:
.setExecutors(AsyncTask.THREAD_POOL_EXECUTOR, new MainThreadExecutor())
to your RestAdaptor.Builder. This moves all of the HTTP requests into the AsyncTasks pool which is then handled by espresso.
I found the original answer here: http://www.michaelevans.org/blog/2015/08/03/using-espresso-for-easy-ui-testing/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With