googletest icon indicating copy to clipboard operation
googletest copied to clipboard

gtest_main does not discover any tests on Windows (Visual Studio)

Open kraiskil opened this issue 5 years ago • 14 comments

I am using googletest in my project without problems on Linux (Ubuntu 16.04, 18.04) and Mac. Now porting the same source to Windows (Visual Studio 15 2017), my googletest binary doesn't find any tests:

 Running main() from gtest_main.cc 
[==========] Running 0 tests from 0 test cases. 
[==========] 0 tests from 0 test cases ran. (1 ms total)
[  PASSED  ] 0 tests.

(same if I link in gmock_main instead of gtest_main). Now, if I compile in a separate main.cpp:

#include <gmock/gmock.h>
int main(int argc, char *argv[]) {
    testing::InitGoogleTest(&argc, argv);
    testing::InitGoogleMock(&argc, argv);
    return RUN_ALL_TESTS();
}

instead of the one provided in gtest_main or gmock_main libraries everything works.

I'm using CMake to build my project, and I don't set any googletest specific settings except -DGTEST_LINKED_AS_SHARED_LIBRARY

Tested with versions master branch versions 98a0d00 and efecb0b

kraiskil avatar Feb 28 '19 18:02 kraiskil