Code coverage error (No binaries were instrumented)
<h2>Problem:</h2>

<p>Microsoft Visual Studio Enterprise 2015</p>

<p>Version 14.0.25431.01 Update 3</p>

<p>I'm attempting to use the code coverage function but it returns this error:</p>

<blockquote>
  <p>Empty results generated: No binaries were instrumented. Make sure the 
  tests ran, required binaries were loaded, had matching symbol files,
  and were not excluded through custom settings. For more information
  see <a href="http://go.microsoft.com/fwlink/?LinkID=253731" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkID=253731</a></p>
</blockquote>

<p>My .coverage file is full of non-sense, starting with "PCHÿ". I thought my problem looked similar to this one: <a href="https://stackoverflow.com/questions/16504992/issue-with-code-coverage-in-vs-2012">Issue with Code Coverage in VS 2012</a>, but deleting the .suo file and running Visual Studio in admnistrator didn't solve anything.</p>

<h2>How to replicate:</h2>

<p>1) Create new empty project "MyProject"</p>

<p>2) Add new file "Calculator.hpp"</p>

<pre><code>#pragma once

class Calculator
{
public:
    int add(int a, int b);
    int sub(int a, int b);
};
</code></pre>

<p>3) Add new file "Calculator.cpp"</p>

<pre><code>#include "Calculator.hpp"

int Calculator::add(int a, int b)
{
    return a + b;
}

int Calculator::sub(int a, int b)
{
    return a - b;
}
</code></pre>

<p>4) Add new file main.cpp</p>

<pre><code>#include "Calculator.hpp"
#include &lt;iostream&gt;

using std::cout;

int main()
{
    Calculator calc;
    std::cout &lt;&lt; calc.add(5, 11) &lt;&lt; std::endl;
    std::cout &lt;&lt; calc.add(11, 1) &lt;&lt; std::endl;

    return 1;
}
</code></pre>

<p>5) Build solution. (0 errors)</p>

<p>6) Add new test project to solution as explained here: <a href="https://msdn.microsoft.com/en-us/library/hh419385.aspx#objectRef" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/hh419385.aspx#objectRef</a>:</p>

<ol>
<li>Add new Native Unit Test Project to solution "CalculatorUnitTest"</li>
<li>Add "main.obj" and "Calculator.obj" to Linker/Input/Additional Dependencies of "CalculatorUnitTest"</li>
<li>Add path to obj files to Linker/General/Additional Library Directories of "CalculatorUnitTest". (In my case: D:\JF\Programming\Tests\MyProject\MyProject\Debug)</li>
<li>Add the header directory of "MyProject" to VC++ Directories/Include Directories. (In my case: D:\JF\Programming\Tests\MyProject\MyProject).</li>
</ol>

<p>7) Replace code in "unittest1.cpp" with:</p>

<pre><code>#include "stdafx.h"
#include "CppUnitTest.h"
#include &lt;Calculator.hpp&gt;

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace CalculatorUnitTest
{       
    TEST_CLASS(UnitTest1)
    {
    public:

        TEST_METHOD(TestMethod1)
        {
            Calculator calc;
            Assert::AreEqual(5, calc.add(2, 3));
        }

    };
}
</code></pre>

<p>8) Build solution (0 errors, TestMethod1 appear in Test Explorer)</p>

<p>9) Right-click TestMethod1, "Run Selected Tests" (Test successfully passes)</p>

<p>10) Right-click TestMethod1, "Analyze Code Coverage for Selected Tests" (Code coverage fails).</p>

<p>At D:\JF\Programming\Tests\MyProject\Debug, I have both my MyProject.exe and MyProject.pdb with the CalculatorUnitTest.dll.</p>