eranpeer / FakeIt

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

Documentation does not report means of verification for destructor call. #158

Open alooow opened 5 years ago

alooow commented 5 years ago

The Quickstart (https://github.com/eranpeer/FakeIt/wiki/Quickstart) documentation mentions that it is possible to stub or fake a destructor. However it does not provide information on how to Verify whether a destructor was called (as it the case of other, "regular", methods). Is such a feature available, and if so, could the documentation be updated to account for this issue?

alibabashack commented 5 years ago

If the mocking syntax is When(Dtor(mock)).Do([](){ ... }); then the verification syntax should be Verify(Dtor(mock)).Once() and alike, I guess. I never used this feature. Could you try this? If it works, please add the desired documentation in a pull request. You probably know best what would have helped you in the first place.

Crypthead commented 4 years ago

If the mocking syntax is When(Dtor(mock)).Do([](){ ... }); then the verification syntax should be Verify(Dtor(mock)).Once() and alike, I guess. I never used this feature. Could you try this? If it works, please add the desired documentation in a pull request. You probably know best what would have helped you in the first place.

Unfortunately this does not seem to work.

A workaround I decided to use is using global variable that is updated in the faked destructor, and after the call to your tested code verify that the value in said global variable is the one expected.