Is it possible to spy on a callback which is given as argument to the system under test?
class SpyCallbackClass
{
public:
virtual void cb() const {
}
};
class SUT
{
public:
SUT(const std::function<void(void)>& cb) :
callback(cb)
{
}
void DoStuff()
{
//Here for example, i want to test whether SUT does call cb
}
private:
const std::function<void(void)>& callback;
};
I managed to resolve the issue. The problem was with my bind function, i was not using a pointer to the SpyCallbackClass but the object returned from Mock::get()
Is it possible to spy on a callback which is given as argument to the system under test?