csoltenborn / GoogleTestAdapter

Visual studio extension that adds support for the C++ testing framework Google Test.
Other
143 stars 100 forks source link

Test discovery fails if executable depends on gmock.dll but not on gtest.dll #315

Open voltamund opened 4 years ago

voltamund commented 4 years ago

I used the default installation (no indicator file and no custom regex). The test executable only depends on gmock.dll (verified with dumpbin). In that case IsGoogleTestExecutable returns false because it expects gtest.dll as a dependency. As a workaround I could set a custom regex. Then test discovery succeeds.

csoltenborn commented 3 years ago

I just noticed that I never reacted to this issue - sorry for that...

For my understanding (currently not working with C++): I assume that the gmock.dll you are using also contains the gtest stuff, but is this the common case? Wouldn't one expect executables to have both dependencies?

csoltenborn commented 3 years ago

I will tag this as enhancement, and it is a very simple change. However, I'm not convinced that this is a common case - feel free to change my mind :-)

sebkraemer commented 2 years ago

Hi. I found this ticket because I'm struggling with undiscovered tests in a project where I (was) moved from some ancient 1.8.something static gtestd.lib to 1.11.0 shared library build by vcpkg.

I can't say if this issue is relevant for my problem but regarding the posed question here I found two hints:

A user states in this conan issue: gmock built as a shared library must use static gtest (I could not find the original README quote after a quick search though.)

There is another ticket that reports convincing reasons against using both gtest.dll and gmock.dll for the same binary (TLDR: both don't share a global variable that's supposed to be unique in the binary) at the googletest repo. Understandably, Google treats this more as a user/build issue than something to be fixed in the googletest project.

I just ran my test binary (without TestExplorer), which is only linked against gmock.dll, it must contain the gtest part statically since there is no gtest.dll in that folder or %PATH%.

I didn't go as far as looking up or trying if conan changed Google's CMake project also includes gtest in the gmock library:

if (MSVC)
  cxx_library(gmock
              "${cxx_strict}"
              "${gtest_dir}/src/gtest-all.cc"
              src/gmock-all.cc)

This closes the circle to the other bincrafters/conan issue. Google does it now like the user proposes. So it should hardly ever be necessary to link against both.

Maybe that changes your mind? :)

csoltenborn commented 2 years ago

It probably does :-) Would you be willing to give a new version a try and see whether it indeed fixes your particular discovery problem? That would most likely push me over the edge :-)

sebkraemer commented 2 years ago

I'd be delighted 😁