You need to build and test the application with gradle build. The RKTracer tool will automatically add a runtime library to the application when you integrate and build the application with the RKTracer tool.
Enable RKTracer with rktracer gradle -on build.gradle, run gradle rebuild, run your tests, generate the HTML report with rkresults, then disable with rktracer gradle -off build.gradle.
Enable RKTracer Tool
To instrument with the RKTracer tool, you need to enable RKTracer before running the gradle build command to build the application. You should always rebuild the project to instrument the application with the RKTracer tool.
The RKTracer tool makes internal adjustments to the gradle build to instrument all the source files compiled at build time. By default, rktracer instruments for multiple-condition code coverage.
gradle build
rktracer gradle -on build.gradle
gradle rebuild
Run tests on instrumented application
When executing unit or functional tests, the RKTracer tool will save coverage data to the rk-coverage.txt file on the host or phone device.
For device testing, you can pull the coverage data:
adb pull /data/data/com.example.widecolor/rk-coverage.txt
Generate Code Coverage HTML reports
After obtaining the rk-coverage.txt file, run rkresults against your build.gradle file.
# Linux rkresults app/build.gradle # Windows rkresults app\build.gradle
The reports are generated in project folder/rktracer/reports/ and can be accessed via index.html.
Once the reports are generated, you need to disable the RKTracer tool with rktracer gradle -off build.gradle.
Enable coverage for selected files
Edit rktracer.config and add directives to scope coverage to specific folders, files, or functions.
ignore *.java instrument */power/* */core/* */keys/* never */firmware_loader/* */lockdown/*
Alternatively, target specific functions:
function-ignore * function-instrument fun_X() fun_Y() fun_Z()
Next steps
Once your Gradle build reports coverage, the same RKTracer workflow applies across other build systems and IDEs. Browse the rest of the documentation, or read more about how RKTracer measures coverage through MC/DC.