eranpeer / FakeIt

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

Provide meaningful message that method is called but not "mocked" #193

Closed Warchant closed 1 year ago

Warchant commented 4 years ago

Actual behavior:

struct Interface {
  virtual void foo() = 0;
};

Mock<Interface> mock;
Interface& face = mock.get();

face.foo(); // called, but not faked

Get this line when using with Boost.Test:

unknown location(0): fatal error: in "<testname>": unknown type

Expected behavior: See some human-readable message, that method is not faked/mocked, but called.

Version: 6d67a1d1a6f906d89217cb248b6c09abf4b33e1e

FranckRJ commented 2 years ago

Did you used the boost integration or the standalone version of FakeIt?

For the standalone it's kind of expected, as it must throw a type that won't be caught by the tested code (we want the exception to unwind at least until the test code), so we throw something that doesn't inherit from std::exception, ence why boost.test won't caught it.

In the integrations we try to throw something that won't be caught by the tested code but will be caught by the testing framework, as we know exactly which one it is, we can tailor the exception type to work with it.

FranckRJ commented 1 year ago

For me what we're doing is good enough. If you can show me a bad message while using the right configuration of fakeit (depending on your test framework) I'll reopen the issue.