Вот упрощенная версия кода:
Код: Выделить всё
class App {
public:
auto OnMethod() -> std::string {
std::string result{ ::Service::Daemon::Run(*this, *this) };
return result;
}
std::string Start(){
std::string result = do_start_something();
return result;
}
std::string Stop(){
std::string result = do_stop_something();
return result;
}
auto wait(){
wait something
}
};
namespace Service {
class Daemon {
public:
static std::string Run(const App& handler, const App& service) {
service.Start();
service.wait();
Service.Stop();
}
};
}
Код: Выделить всё
class MockApp : public App {
public:
MOCK_METHOD(::std::string, Start, (), (override));
MOCK_METHOD(::std::string, Stop, (), (override));
}
TEST_F(MockApp, OnMethod){
MockApp *mockapp;
EXPECT_CALL(mockapp, Start(::testing::_).WillOnce(::testing::Return(return_value));
EXPECT_CALL(mockapp, Stop(::testing::_).WillOnce(::testing::Return(return_value));
mockapp->OnMethod();
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... test-gmock