Instrument an Android app to measure the test coverage.
Take method coverage as an example, the steps to measure the method coverage of dyn. analysis are as follows:
- Analyze the app and get a list of all statements belonging to classes which share the app package name.
- Instrument the app to print log messages when it reaches each statement.
- Run the app and collect the log messages.
- Get the list of reached methods.
- Calculate the coverage (i.e. the percentage of reached statements).
./gradlew build
./gradlew shadowJar
java -jar androcov.jar -o <directory> -i <APK> [-h] -sdk <android.jar>
-o,--output <directory> path to output dir
-i,--input <APK> path to target APK
-h,--help print this help message
-sdk,--android_jar <android.jar> path to android.jar