Use this guide to generate code coverage for a C# application developed in the Visual Studio IDE with RKTracer, in three simple steps:
- Enable the RKTracer tool and rebuild the application.
- Test the instrumented application and save the coverage data.
- Generate the code coverage reports.
Integrate RKTracer into Visual Studio, turn RKTracer ON from the Tools menu, rebuild and run your tests, then choose RKTracer Report from the Tools menu to generate the HTML report.
Code coverage tool integration with Visual Studio IDE
Close all instances of the Visual Studio IDE. Open a new command prompt and run the integration command:
rktracer -vs -integrate
Once successfully integrated, the RKTracer tool options appear in the Tools menu.
Enable the RKTracer tool
Navigate to the Tools menu and select RKTracer ON.
Rebuild and run tests
Testing can be unit testing or functional testing. Rebuild your application and execute your test suite.
Generate Code Coverage reports
Go to the Tools menu and select RKTracer Report to generate the HTML reports. The tool processes the coverage data file rk-coverage.txt and maps it with the JSON files in the rktracer folder to create the HTML reports. Open index.html manually to view the results.
Enable coverage for selected files
You can scope coverage to specific folders, files, or functions by editing rktracer.config. For example, add configuration like:
ignore *.cs instrument */power/* */core/* */keys/* never */firmware_loader/* */lockdown/*
ignore *.csignores all C# source files.instrument */power/* */core/* */keys/*instruments the specified folders.never */firmware_loader/* */lockdown/*excludes the selected directories.
For specific functions, configure:
ignore *.cs instrument *source-file-X.cs *source-file-Y.cs *source-file-Z.cs function-ignore * function-instrument fun_X() fun_Y() fun_Z()