Testing Volley with espresso

141 Views Asked by At

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.

0

There are 0 best solutions below