How to get test results using "adb shell am instrument"

I am running some tests on my Android device using the following command:

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

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

thanks

+6
source share
3 answers

But does this process also create a result file inside the device (xml, html, etc.)?

No, it is not.

Report generation is usually handled at a higher level than am instrument. If you run tests using Gradle, it should generate a report for you. I believe this is what Android Studio relies on.

If you need to generate a report from the test itself, you can use your own test runner. See this answer for one way to do this: http://www.stackoverflow.com/a/5574418/1999084

+5
source

I had a similar problem (I wanted to have xml test reports for my Jenkins when it runs control tests on the device). I solved this by running "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' 

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

To use it, add:

 -e listener de.schroepf.androidxmlrunlistener.XmlRunListener 

to your appliance team.

And to get the XML report file use:

 adb pull /storage/emulated/0/Android/data/<your-app-package-name>/files/report.xml 
+5
source

If you run your tests using AndroidTestOrchestrator , your XML test results are generated and stored inside the storage/emulated/0/odo/ . Thus, they can be accessed using:

adb pull storage/emulated/0/odo/

I am not sure why this is not mentioned anywhere in the documentation. This path is likely to be different for real devices, where I believe that the results are displayed on the SDCARD somewhere.

0
source

All Articles