Product
Solutions
Resources
Company
Download Trial Book a Demo

C# Code Coverage for Applications in Visual Studio

Generate C# code coverage for an application developed in the Visual Studio IDE using RKTracer in three simple steps. Enable the RKTracer tool and rebuild the application, test the instrumented application and save the coverage data, then generate the code coverage reports.

Use this guide to generate code coverage for a C# application developed in the Visual Studio IDE with RKTracer, in three simple steps:

  1. Enable the RKTracer tool and rebuild the application.
  2. Test the instrumented application and save the coverage data.
  3. Generate the code coverage reports.
In short

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:

integrate rktracer with visual studio
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:

rktracer.config
ignore *.cs
instrument */power/* */core/* */keys/*
never */firmware_loader/* */lockdown/*
  • ignore *.cs ignores all C# source files.
  • instrument */power/* */core/* */keys/* instruments the specified folders.
  • never */firmware_loader/* */lockdown/* excludes the selected directories.

For specific functions, configure:

rktracer.config
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()

Stuck on your build?

Open a support ticket and an engineer who knows your toolchain will help. You get a tracked ticket ID by email.