I am trying to set up unit testing with code coverage in VS2008, for a C ++ / CLI library that is compiled with / clr (not / clr: safe or / clr: pure - it must be / clr because it uses MFC).
Unit tests work fine, but coverage information only works when compiled with / clr: safe or / clr: pure. For / clr, the following message is displayed in the code coverage result window:
Empty results: none of the tools used were binary systems. Look at trial run information for any hardware problem.
I also tried " goroadroad ", but when I load the coverage file in VS, it also contains empty results.
It is annoying that I can not find anywhere specifically saying whether Code Coverage works with / CLR, so I just had to try it myself.
If this works, can anyone see what I'm doing wrong here?
[File] → [New] → [Project]
Select Class Library, enter MyProj as the project name, click OK
Right-click the MyProj project, select [Properties]
Select [Configuration Properties] → [General]
Verify that the "Common Language Runtime" is set to / CLR
Add this code to Class1:
public:
static int calc() { return 69; }
Solution assembly
[] → [ ] → [Unit Test], "" , ""
TestMethod1:
Assert::AreEqual(MyProj::Class1::calc(), 69);
TestProject1, []
" "
"MyProj" "", "" , ""
[] → [ ] → [ ]
[ ]
MyProj.dll, "", ""
[Test] → [Run] → [All Tests in Solution]
, TestMethod1.
" " :
: . .
MyProj, []
[ ] → []
"Common Language Runtime" /CLR: SAFE /CLR: PURE, OK
[Test] → [Run] → [All Tests In Solution]
, TestMethod1.
" " .