lundi 17 octobre 2016

Using Espresso to perform UI test, how could I access&use the Log.d produce by the target Activity?

thank you for your time in advance )

Background:

I am currently trying out the Espresso library to perform Android UI test.

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'

It is running fine right now.

Question:

What I am trying to do is to directly "read" the log output from the target activity using Esspreso.

For example:

  1. I have an activity called OpenGL20Activity need to be tested.
  2. There are 3 editTextView and 1 button in this Activity
  3. after hitting the button, lets say the app will fire some http requests according to the 3 value in editTextView, which will only be seen in log, since it is a 3rd party call.

    eg:

    10-17 16:32:24.806 5333-5372/? I/http_client.cpp: http_request.path=$%^&#N %^$

  4. I have to test agaist this http request by grabing the log and analize it

So, how could I grab the log directly using Espresso without touching the original code?

Alternative: Just out of curiousity, I could probably create a textView and print the log to it in some thread and read against that textView I guess

Which one will be better and how to get log.d print inside normal activity?

Process process = Runtime.getRuntime().exec("logcat -d");

doesn't work, gives I/System.out: null

Aucun commentaire:

Enregistrer un commentaire