Testing Android with logcat to capture events

I have been looking for this problem for many hours, and I'm at a dead end. I am trying to write a comprehensive test suite for Android devices, and my first idea was to check the test results using logcat output. Logcat has all the event information that I need both from the OS and from our applications.

Using Robotium or Monkeyrunner, I could not find access to logcat on the fly. Creating an external application for monitoring logcat is out of the question (it is difficult to synchronize events with the results).

Any ideas guys?

+4
source share
2 answers

Try it. Add the following permissions to the Robotium manifest file:

<uses-permission android:name="android.permission.READ_LOGS" /> 

Then create a stream in your installation method and do the following:

 Process proc = Runtime.getRuntime().exec("logcat -d"); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); 

Then read using:

 reader.readLine() 
+6
source

Use the logcat -d -v time option on regular breakpoints, then analyze it. will this help?

+1
source

Source: https://habr.com/ru/post/1400999/


All Articles