An Appium server for Android to generate JaCoCo coverage data.
This server app has zero runtime dependency, which eliminates the possibility of dependency conflict between this test driver and the target app, as both apps share the same classpath.
-
In
app/build.gradle, changeTARGET_PACKAGEin the following line to the package name of your app of interestmanifestPlaceholders = [targetPackage:"TARGET_PACKAGE"]
-
Either build in Android Studio, or run the following command
./graldew assembleDebug
-
You should be able to find the APK file at
app/build/outputs/apk/debug/app-debug.apk
For the Android instrumentation framework to collect coverage data, the app under test must be pre-instrumented before installed to the phone. A simple way is to add the following to your gradle script and build the debug version (e.g., assembleDebug).
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}Appium Coverage can be used either with Appium or standalone (through adb). For either approach
- I will assume both this app and the pre-instrumented target app have been installed on the phone
- Don't stop the app in the middle of the test
- After the test, the JaCoCo coverage file is at
/sdcard/Android/data/<your test package>/files/coverage.econ the phone
Configure the following desired capabilities and perform the test as usual
appPackage: the package ID of your target appappActivity: the activity that appears after app launchandroidCoverage:edu.purdue.dsnl.appiumcoverage/.CoverageInstrumentationandroidCoverageEndIntent:edu.purdue.dsnl.appiumcoverage.END_EMMA
adb shell am instrument -w edu.purdue.dsnl.appiumcoverage/.CoverageInstrumentation, and the app will automatically launch- Do what ever you want with the app, except stopping it
adb shell am broadcast -a edu.purdue.dsnl.appiumcoverage.END_EMMA