You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I verify that a child class calls a function on the parent class. In the sample below, I have separate unittests for class A. But when testing class B I want to verify that it indeed calls its parent class' test function. Is this possible using fakeit?
#include "fakeit.hpp"
#include <iostream>
class A {
public:
virtual void test() {
a = 5;
}
int a;
};
class B: public A {
public:
virtual void test() {
A::test();
b = 3;
}
int b;
};
void test_B_test() {
B *b = new B();
fakeit::Mock<B> spy(*b);
b->test();
//Verify somehow that A::test was called
std::cout << b->a << " " << b->b << std::endl;
}
int main() {
test_B_test();
}
The text was updated successfully, but these errors were encountered:
No it's not possible currently and I don't see how we can implement it. The way mocks work is by creating a sub-class that inherit from the class you want to mock, and alter the V-Table to redirect the call to the function we want to be called. When you use a fully qualified name to call your method (in the form Class::method) the call won't go through the V-Table, so we can't redirect it or do anything with it.
I'll keep it open in case anyone have an idea but I guess it will never be implemented.
How can I verify that a child class calls a function on the parent class. In the sample below, I have separate unittests for
class A
. But when testingclass B
I want to verify that it indeed calls its parent class'test
function. Is this possible using fakeit?The text was updated successfully, but these errors were encountered: