Can't run tests in CppUnitTestFramework (VS2013)

1.4k views Asked by At

On a separate perforce stream from the rest of my team, I can't run CppUnitTestFramework tests on a project, while the rest of the streams run the tests just fine.

Here's a code snippet:

TEST_CLASS(MyClass)
{
    BEGIN_TEST_CLASS_ATTRIBUTE()
        TEST_CLASS_ATTRIBUTE(L"Type", L"Native C++ Unit Tests")
        TEST_CLASS_ATTRIBUTE(L"TestClass", L"MyClass")
        END_TEST_CLASS_ATTRIBUTE()

public:

    TEST_METHOD(canFooTheBar)
    {
        ...
        Assert::IsTrue(foo());
    }
...
}

Here is the error I get when trying to run a test:

------ Discover test started ------
Object reference not set to an instance of an object.
========== Discover test finished: 0 found (0:00:00.5129487) ==========
No tests found to run.

There are no diffs between the .sln, or any of the relevant .vcxproj files between the different streams.

1

There are 1 answers

1
zvisofer On BEST ANSWER

A possible reason is that you have a test class that has no tests (in the same project).

Removing such class may solve the problem.

The problem is reproduced if I add the following class to the project:

TEST_CLASS(MyEmptyClass)
{
    BEGIN_TEST_CLASS_ATTRIBUTE()
        TEST_CLASS_ATTRIBUTE(L"Type", L"Native C++ Unit Tests")
        TEST_CLASS_ATTRIBUTE(L"TestClass", L"MyEmptyClass")
        END_TEST_CLASS_ATTRIBUTE()

public:
    //no tests
}