eranpeer / FakeIt

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

Added a macro to enable assert on unexpected method invocation #99

Closed alexey-malov closed 6 years ago

alexey-malov commented 7 years ago

If FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION macros is defined before including fakeit, an assertion is fired when unmocked method is called. This simplifies detection of unmocked method using call stack tracking in debug mode.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 99.974% when pulling cc751890e6991c145acb3e03121aea44a434f9e9 on alexey-malov:assert_on_unmocked_method_invocation into 1591275d7124af083ab95f8ab62c99dabaea7782 on eranpeer:master.

alexey-malov commented 7 years ago

Currently, if an unmocked method is called, it is hard to determine which method was called. I suggest adding a macro FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION. If this macro is defined, the assert will fire on unexpected method invocation. This gives a programmer a chance to break into debugger and determine a context that caused an unmocked method invocation by viewing call stack.