0

I built an android app using volley to fetch data from a remote server. I am trying to test the app using espresso. can anyone help me with the code for that? if I take the simplest example, I am trying to get the data from the server, and set it as text in a TextView. I already created the app that does it, what I'm trying to do is to create the test for it. thank you.

Edit: this is a simplified version of the code I'm trying to test

JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, myUrl, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject responseObject) {
        
           String textMessage = responseObject.get("message");
           
           TextView textView = findViewById(R.id.text_view);
           
           textView.setText(textMessage);
        }

}

this is what I'm trying to test using instrumental testing (espresso)

I am using Volley as a 3rd party library. the data is in private server.

  • What have you tried so far? Please edit your question and mention where you are stuck! And from which remote server you want to get the data what is its JSON formant (if it is in JSON)? – Rajnish Sharma Jul 26 '20 at 18:55
  • You have to use idle resource https://developer.android.com/reference/androidx/test/espresso/idling/CountingIdlingResource it basically tells espresso when is busy and when is not – cutiko Jul 27 '20 at 23:32
  • can you walk me a bit more here? i did some reading, but i didn't really get what is done with it? when do i tell espresso to wait and when do i tell it to come back? – Ariel Applebaum Aug 08 '20 at 17:00

0 Answers0