Code Coverage for Visual Studio IDE
In this 3mins video, you will see how to generate code coverage for applications in visual studio ide using RKTracer Tool with 3 simple steps.
- Enable the RKTracer tool and rebuild the application.
- Test instrumented application and save coverage data.
- Generate code coverage reports
Code Coverage tool integration with Visual Studio IDE
Open a new command prompt and execute the following command to integrate the RKTracer tool with visual studio IDEs.
On successful integration of the RKTracer tool, you should see the following information in the command prompt.
rktracer -vs -integrate
Open Visual Studio IDE, and you should be able to see RKTracer tool options in the Tools menu.
- RKTracer ON: Will enable RKTracer tool for instrumentation
- RKTracer OFF: Will disable RKTracer tool.
- RKTracer Reports: Will generate reports in HTML format.
Generate Code Coverage for Application in Visual Studio IDE.
To Instrument, test, and generate code coverage in Visual Studio IDEs (2015 to 2022). Make sure you are able to build and run the unit/functional tests of the application. Testing can be on a host or server machine.
Enable Code Coverage Tool
Go to → Tools → RKTracer ON.
Rebuild application and run tests
Generate Code Coverage Reports
Go to –> Tools menu –> RKTracer Report to generate Html reports. The RKTracer tool will internally convert data in “rk-coverage.txt” and map with JSON files (generated during instrumentation) in the rktracer folder and generate the HTML reports. You can manually open the HTML report using index.html.
Enable coverage for selected files
Generate coverage reports for the selected folders
C:projectsounddriversbasepower
C:projectsounddriversbasepowerfirmware_loader
C:projectsounddriverscore
C:projectsoundsecuritykeys
C:projectsoundsecuritylockdown
Suppose you need code coverage for source files from three different folders, i.e., core, keys, power, and ignore coverage for folders firmware_loader and lockdown. Edit rktracer.config in the RKTracer installation folder and go to the end of the file add the following information.
ignore *.c
instrument */power/* */core/* */keys/*
never */firmware_loader/* */lockdown/*
ignore *.c = Ignores all C source files from instrumentation
Instrument = Instrument source files from given folders
never = ignore selected folder
Generate coverage reports only for selected functions from three different files.
fun_X() in source-file-X
fun_Y() in source-file-Y
fun_Z() in source-file-Z
Suppose you need code coverage for selected functions from three different files. Edit rktracer.config in the RKTracer installation folder and go to the end of the file and set the following variables as shown below.
ignore *.c
instrument *source-file-X.c *source-file-Y.c *source-file-Z.c
function-ignore *
function-instrument fun_X() fun_Y() fun_Z()
ignore *.c = Ignore all C programming source files
instrument *file-X.c *file-Y.c *file-Z.c = Instrument only these three source files.
function-ignore * = Then ignore all functions in the above three files.
function-instrument fun_X() fun_Y() fun_Z() = Don’t ignore these three functions from these three files from instrumentation