This is going to be a self-answered, FAQ-style question. See answer below.
With Visual Studio 2017/2019 it is really easy to set up a new Google Test project and start writing tests (as long as you don't mind using older versions of GoogleTest versions anyway).
But what about using GoogleMock as well? You would think that since Google combined gtest/gmock some time ago that this would just work. Just #include "gmock/gmock.h" and mock away. But no, the GoogleTest NuGet package that is automatically added by the template does not include the gmock folder at all.
Trying to add a second GoogleMock NuGet package causes multiple problems, such as mismatched gtest/gmock versions, overlapping include paths, etc.
Replacing the Microsoft GoogleTest NuGet package with the one from Google causes a link error:
MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
So what is the current recommended (and least painful) way to set up GoogleTest/GoogleMock in Visual Studio? Tests should be able to be discovered, run, and debugged via the Test Explorer.



