1

I'm installing unittest++ on MacOS maverick, and come accross this compiling error:

src/tests/TestXmlTestReporter.cpp
src/tests/TestCurrentTest.cpp
Linking TestUnitTest++...
Running unit tests...
:107: error: Failure in test: Expected 2 but was 0
FAILURE: 1 out of 174 tests failed (1 failures).

How to fix this problem? I have no problem with older version of MacOS.

1 Answer 1

0

I ran into this. It looks like there is an error in the UnitTest++ test code. It implements a number of mock tests in src/tests/TestTestRunner.cpp, but they all have the wrong signature for of Test::RunImpl(). RunImpl expects no arguments, but the mock test's RunImpl provides a reference to a TestResults object.

e.g. on l25 of TestTestRunner.cpp:

 virtual void RunImpl(TestResults& testResults_) const
 {
    for (int i=0; i < count; ++i)
    {
        if (asserted)
            ReportAssert("desc", "file", 0);
        else if (!success)
            testResults_.OnTestFailure(m_details, "message");
    }
 }

but because the signature doesn't match, it should be:

 virtual void RunImpl() const
 {
    TestResults* testResults_ = CurrentTest::Results();
    for (int i=0; i < count; ++i)
    {
        if (asserted)
            ReportAssert("desc", "file", 0);
        else if (!success)
            testResults_->OnTestFailure(m_details, "message");
    }
 }

So the solution is to fix all the RunImpl in a similar way.

I'm not sure why/how it compiled and ran successfully on earlier OSX platforms.

UPDATE: After resolving this, I discovered there is actually an open ticket for this: http://sourceforge.net/p/unittest-cpp/bugs/23/ - but the project maintainers don't seem very active of late.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .