Member-only story

Code Coverage for Native Unit Testing in C++

Guriy Samarin
2 min readMay 12, 2019

This is part two of my “how to start Unit Test C++ guide” (the first part). If you decided to use Native Unit Test Project

7. And include #include “your_header_name.h” into it (#include “../ConsoleApp/check.h” in my example) into a unit test file (unittest1.cpp)

8. Now you can create tests in this file. For example

Steps 9,10 stays the same. But you could face two problems:

I. If you run tests you will probably see “Cannot discover test extensions installed by NuGet. The NuGet service is not available. Tests may not be found due to missing test adapter extensions” warning.

To fix this in Visual Studio Go to Tools -> Extensions and Updates. Switch to Online and search for “Nunit test adapter” and install it

II. The Code Coverage Results could be completely empty (the Code Coverage Results window shows 0% code “covered” as well as 0% “not covered”).

It’s probably because Unit Test projects are built for faster links. In order to use Code Coverage Analysis…

--

--

Guriy Samarin
Guriy Samarin

Written by Guriy Samarin

Software developer at Amazon. Web (mostly backend) development now. My stack — .NET (APS.NET Core MVC).

No responses yet