An AndroidJUnitRunner RunListener implementation which will create JUnit compatible XML report files containing the results of Andorid Instrumentation tests.
Add the dependency to the dependencies
section of your app's build.gradle
file of:
androidTestImplementation 'de.schroepf:android-xml-run-listener:0.4.0'
androidTestImplementation 'de.schroepf:android-xml-run-listener-legacy:0.4.0'
Add the following to your app's build.gradle
file's defaultConfig
section:
android {
defaultConfig {
//...
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArgument "listener", "de.schroepf.androidxmlrunlistener.XmlRunListener"
}
When you don't want to add the XmlRunListener to your project's gradle config you may add the following option:
-e listener de.schroepf.androidxmlrunlistener.XmlRunListener
to the adb shell am instrument
command, e.g.:
adb shell am instrument -w -r -e listener de.schroepf.androidxmlrunlistener.XmlRunListener -e debug false de.schroepf.demoapp.test/android.support.test.runner.AndroidJUnitRunner
The report.xml
files will be stored in the tests application's documents folder, e.g.:
adb shell cat /sdcard/Android/data/de.schroepf.demoapp/files/report*.xml
to copy them from the device to the computer:
adb pull /sdcard/Android/data/de.schroepf.demoapp/files
Bofore starting the next test run make sure to remove the report XML files from the device either by uninstalling the app before running the test again or by executing:
adb shell rm /sdcard/Android/data/de.schroepf.demoapp/files/report*.xml