I have C++/CLI code and I'm using Visual Studio 2008 Team Suite Code Coverage.
The code header:
// Library.h
#pragma once
#include <string>
using namespace System;
namespace Library
{
public ref class MyClass
{
public:
static void MyFoo();
static std::string Foo();
};
}
The code implementation:
#include "Library.h"
using namespace Library;
using namespace System;
void MyClass::MyFoo()
{
Foo();
}
std::string MyClass::Foo()
{
return std::string();
}
I have a C# unit test, that calls MyClass.MyFoo()
:
[TestMethod]
public void TestMethod1()
{
Library.MyClass.MyFoo();
}
For some reason, I don't get a full code coverage for MyClass
. The Foo() method has 3 uncovered blocks and 5 covered blocks. The closing curly brackets (}
) are marked in orange - partially covered. I have no idea why is it partially covered instead of fully covered, and this is my question.
UPDATE
Another Example:
Header:
// Library.h
#pragma once
using namespace System;
namespace Library
{
struct MyStruct
{
int _number;
};
public ref class MyClass
{
public:
static void MyFoo();
static MyStruct* Foo();
};
}
Implementation:
#include "Library.h"
using namespace Library;
using namespace System;
void MyClass::MyFoo()
{
delete Foo();
}
MyStruct* MyClass::Foo()
{
return new MyStruct();
}
I'm still getting the same missing coverage in Foo's return
statement.