I have an .exe file which loads a .dll file dynamically. The .dll file is passed as an argument to the program. Can I get code coverage of the .dll file using any coverage tools? What tools can I use and how to use them?

Command: opencppcoverage.exe -- <filename>.exe <dll filename>.dll

The .dll file is written in C++ and I have the source code for the .dll file and not for the .exe file.

  • How do you like opencppcoverage?
    – Travis
    Jul 14, 2017 at 14:36

2 Answers 2


Semantic Designs C and C++ test coverage tools can do this for MS source files. [There's a version that works with GCC, too.]

Along with running the instrumenter on the DLL source code, you'll need to add custom logic in the dll shutdown logic to dump test coverage data (or some other place that the dll executes rarely but reliably). The docs explain how to do it. This enables the DLL to collect and report test coverage data on itself without any need for the .exe file to know this is happening.

[To answer a question from another place: This tool will also let you perform multiple executions on typical input data, or, with minor adjustments, on individual tests, and collect coverage data for each run/test separately. You can inspect the coverage for the individual runs, or the tool can combine the data from individual runs to tell you overall coverage of all runs, or you can compare what one run covers versus another.]

Since this is my company, don't take this as a recommendation, just a statement that these tools exist.

  • Can you please share the link to the documentation page.
    – Rope
    May 29, 2015 at 4:58
  • Detailed documentation is not online. You can download a trial copy of the software. It contains the documentation. Suggest you check out the VS2013 version.
    – Ira Baxter
    May 29, 2015 at 8:18

Microsoft Visual Studio Ultimate edition includes test coverage tools.

(I assume it can handle DLLs, but I have no experience with this. Just recording its existence as an alternative.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.