I am trying to determine the location where jacoco will create a coverage file for benchmarks running on real devices.
From the --debug start of the gradle task, I see this log:
[DEBUG] [org.gradle.api.Task] DeviceConnector 'Nexus 5X - 6.0.1': installing /home/martin/workspace/lib/my-lib/build/outputs/apk/my-lib-debug-androidTest-unaligned.apk [INFO] [org.gradle.api.Task] Starting 1 tests on Nexus 5X - 6.0.1 [INFO] [org.gradle.api.Task] de.my.lib.utils.UtilsTest testMyTest[Nexus 5X - 6.0.1] [32mSUCCESS [0m [DEBUG] [org.gradle.api.Task] DeviceConnector 'Nexus 5X - 6.0.1': fetching coverage data from /data/data/de.my.lib.test/coverage.ec [DEBUG] [org.gradle.api.Task] DeviceConnector 'Nexus 5X - 6.0.1': uninstalling de.my.lib.test 13:46:14.538 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':my-lib:connectedDebugAndroidTest'
I tried 3 ways to determine the location:
Using the <instrumentation> in the manifest file did not change anything.
<?xml version="1.0" encoding="utf-8"?> <manifest package="de.my.lib.test" xmlns:android="http://schemas.android.com/apk/res/android"> <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" xmlns:tools="http://schemas.android.com/tools" android:targetPackage="de.my.lib.test" tools:replace="android:targetPackage"> <meta-data android:name="coverage" android:value="true" /> <meta-data android:name="coverageFile" android:value="/sdcard/coverage.ec" /> </instrumentation> </manifest>
I tried it with gradle, but the result was the same:
defaultConfig { // unimportant stuff testApplicationId "de.my.lib.test" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArgument('coverageFile', '/sdcard/coverage.ec') }
And finally, I tried it with the adb command:
adb shell am instrument -w -e coverage true -e coverageFile /sdcard/coverage.ec de.my.lib.test/android.support.test.runner.AndroidJUnitRunner
But there I get 2 errors:
de.my.lib.utils.UtilsTest:. Could not find class: org.jacoco.agent.rt.internal_773e439.CoverageTransformer . Time: 0,072 OK (1 test) Error: Failed to generate emma coverage.
I am completely lost here. Any ideas?
A small background that I need to be stored elsewhere: on some devices and the Android version there is an error with the command "adb shell run-as", so I have devices in my test device farm that return 0% coverage because file cannot be pulled out. Therefore, I need the file to be stored in a public place.