Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve test results when using "adb shell am instrument"

I'm executing some tests in my Android device by using the following command:

adb shell am instrument -w package.name/android.test.runner.AndroidJUnitRunner

I can see the test progress and simple results through STDOUT. But, does this process also generates a results file inside the device (xml, html, etc)? If yes, where is it stored?

Thanks

like image 419
Marcelo Avatar asked Nov 24 '15 14:11

Marcelo


1 Answers

I had a similar problem (I wanted to have xml test reports for my Jenkins when it runs instrumentation tests on a device). I solved it by implementing the "android-xml-run-listener" (https://github.com/schroepf/TestLab/tree/master/android).

To use it simply add:

androidTestCompile 'de.schroepf:android-xml-run-listener:0.1.3'

to your build.gradle (note the androidTest prefix - this will not add code to your production app!).

To use it, add:

-e listener de.schroepf.androidxmlrunlistener.XmlRunListener

to your am instrument command.

And to retrieve the XML report file, use:

adb pull /storage/emulated/0/Android/data/<your-app-package-name>/files/report.xml
like image 196
toby Avatar answered Sep 20 '22 07:09

toby