eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.25k stars 175 forks source link

({Unknown expression after the reported line}) #89

Closed jmcarter17 closed 7 years ago

jmcarter17 commented 7 years ago

Hey Great Library,

One comment though, when I do a Verify call that fails, Catch reports ({Unknown expression after the reported line}) for the Test, but no interesting comment on which line caused the problem, and what that problem was.

I'm using latest Catch (v1.8.2) and FakeIt/single_header/catch/fakeit.hpp (Generated: 2017-03-29 07:39:05.028581).

Here is the code:

TEST_CASE("Test FakeIt") {
    Mock<ICompressor> mockCompressor;
    auto& myComp = mockCompressor.get();

    When(Method(mockCompressor, getState)).Return(ICompressor::compState::idle);
    When(Method(mockCompressor, start)).AlwaysReturn();
    When(Method(mockCompressor, stop)).AlwaysReturn();

    CHECK(ICompressor::compState::idle == myComp.getState());

    myComp.start();
    myComp.stop();
    Verify(Method(mockCompressor, start)).AtLeastOnce();
    VerifyNoOtherInvocations(Method(mockCompressor, stop));
}

Is this because my setup is wrong or is this simply a feature not yet implemented.

Thanks

eranpeer commented 7 years ago

Hi, The message should be more expressive. You're doing nothing wrong. I will look into it this week. Thanks,

eranpeer commented 7 years ago

It should be fixed now. You can use the source or the single_header Catch file. I fixed the Catch integration to work with the latest Catch version. Please try it and update me if needed. Thanks for raising this issue.

jmcarter17 commented 7 years ago

Yes, much better now, thanks for the quick fix.