platformio / platformio-docs

PlatformIO Documentation
https://docs.platformio.org
Apache License 2.0
234 stars 323 forks source link

GoogleTest example miss #include "gmock/gmock.h" for GMock #303

Closed xzxzxc closed 1 year ago

xzxzxc commented 1 year ago

In case you try to follow the following hint of the https://github.com/platformio/platformio-docs/blob/develop/advanced/unit-testing/frameworks/googletest.rst

::testing::InitGoogleTest(&argc, argv);
// if you plan to use GMock, replace the line above with
// ::testing::InitGoogleMock(&argc, argv);

and replace InitGoogleTest with InitGoogleMock, it will fail with an error:

error: no member named 'InitGoogleMock' in namespace 'testing'; did you mean 'InitGoogleTest'?

To fix it, you can add

#include "gmock/gmock.h"

at the beginning of the file.

I'm new to embedded programming and C++ at all, so it wasn't obvious to me, and took time to figure out. I hope the fix can help someone like me.

ivankravets commented 1 year ago

Thanks for the issue!