mardi 24 novembre 2015

C++/CLI unit test code coverage

I have a question about code coverage analysis for C++/CLI unit testing.

I have followed the following tutorial in order to set up code coverage: http://ift.tt/1LxDuCB

The first thing I did was create three project:

  • Proj 1 - A static library project that contains the code I want to test.
  • Proj 2 - An application project (exe) that calls the code in Proj 1.
  • Proj 3 - The unit test project that tests the code from Proj 1.

In Proj 1 I simply have a header file with the following code:

int ToTest()
{
    return 5;
}

In Proj 2 I have just this simple main:

int main()
{
    ToTest();
    return 0;
}

And finally in Proj 3 I have the following unit test:

[TestMethod]
void TestMethod1()
{
    Assert::IsTrue(ToTest() == 5);
};

(The above is based on this tutorial: http://ift.tt/1Ax7XMI)

I have followed the first tutorial, and changed the properties of Proj 2 to have the Profile option on and the (/OPT:NOREF) option as well. I edited the settings of the localtestrun and configured the code coverage by adding the .exe of Proj 3.

I run the unit test, and clicked on the code coverage results. The result I got is the following:

Empty results generated: none of the instrumented binary was used. Look at test run details for any instrumentation problems.

Anyone got any idea why I'm getting this result?

I have even tried to move the ToTest function to Proj 2 and unit test it, but still no results.

Hope someone can Help.

Thanks

Aucun commentaire:

Enregistrer un commentaire