I’m trying to develop more unit tests for specific modules. Testing the module itself is most of the times easy, however, when said module calls other modules it’s necessary to create a mock or override the function. Without the mock, the test enters into a segmentation fault.
I’m having problems with a module which is calling
gcs().send_text(MAV_SEVERITY_CRITICAL, “Lost manual control”);
I’ve tried using google mocks, but it throws an error when including the gmock.h the files. The following code is what I have tried to use to get it running. Including the gmock.h doesn’t work and using just the MOCK_METHOD doesn’t work either.
#include "gmock/gmock.h"
class MockGcs : public GCS {
public:
MOCK_METHOD(void, send_text, (MAV_SEVERITY severity, const char *fmt, ...));
private:
bool error_message_sent = false;
bool notification_message_sent = false;
};
Thanks!