

In this post, I will show you a simple example to go from a C++ source file to a coverage report (in a readable format or in a JSON format which can be parsed to generate custom nice reports or upload results to Coveralls/Codecov). As a proof, we can tell you that we have been using Clang to collect code coverage information on Windows for Firefox.

As already mentioned in the comments, for more advanced configuration and automation check this article.With the upcoming version of Clang 6, support for collecting code coverage information on Windows is now mature enough to be used in production. However, if nothing specific to this version is used within tests, it will work with no problems, regardless of having installed NUnit 3.xx version. EMMA can run on-the-fly or in offline mode. EMMA tests coverage of Java applications and supports many types of coverage like class, method, line, and block. Do a Google search for code coverage tools, and EMMA is the first to show up. NOTE: as mentioned, OpenCoverUI does not support latest major version of NUnit (3.xx). Emma is one of the oldest and most popular of the code coverage tools.

You can also highlight code that is or is not covered (small icon in the top-left). It will output details such as Code Coverage in a tree based view. If it fails, check Output windows for more details.Ĭheck OpenCover Results (within OpenCover menu) for more details. OpenCover Path: this should point to the installed package, usually \packages\OpenCover.4.6.519\tools\Īccess OpenCover Test Explorer from OpenCover menu. This can be found only within NUnit 2.xx version, which can be downloaded from here. NUnit Path: must point to the `nunit-console.exe file. This can be installed directly from Visual Studio by using Tools -> Extensions and UpdatesĬonfigure OpenCoverUI to use the appropriate executables, by accessing Tools -> Options -> OpenCover.UI Options -> General Install OpenCover NUGet component using NuGet interface test (code) coverage and dynamic analysis tool for the C and C++ programming. I will write step-by-step configuration for use with NUnit tests within Visual Studion 2015 Professional. compiler is assumed to be Visual C++ (cl command for compile/link, link. However, it can be obtained quite easily. Toni's answer is very useful, but I thought a quick start for total beginners to test coverage assessment (like I am).Īs already mentioned, Visual Studio Professional and Community Editions do not have built-in test coverage support.
