Closed Baklap4 closed 2 years ago
This issue is not a vcpkg issue.
If you want to enable the testing, please adding include(CTest)
to your top-level CMakeLists.txt
.
|-- CMakeLists.txt
include(CTest)
enable_testing()
This issue is not a vcpkg issue. If you want to enable the testing, please adding include(CTest) to your top-level CMakeLists.txt.
I've added the include(CTest)
before the enable_testing()
yet to no avail. The test explorer stays empty and the executeable lists 0/0 tests while there are plenty.
Please also read my Edit part:
For what it's worth... If we remove the dependency of gmock and also remove it from target_link_libraries and make a unittest which doesn't depend on gmock it does get listed and works perfectly fine.
@Baklap4 Sorry, vcpkg
doesn't currently support test cases for ports. This is probably a VS
bug https://developercommunity.visualstudio.com/t/no-tests-discovered-for-googletest-and-cmake-anoth/1148799.
On the other hand, you can submit an issue with gtest
upstream for help. https://github.com/google/googletest. 🙂
Ping @Baklap4 for response.
We hope your question was answered to your satisfaction; if it wasn't, you can reopen with more info.
Hello
We're trying to implement some unittesting with GTest. It works on linux, but then we wanted to try it out on Windows (through vcpkg) stuff didn't seem to work: The tests we wrote didn't end up listed and we got the error:
Our project structure is:
So within the main
CMakeLists.txt
(in the root of the project) we defined the following:This allows us to find GTest (within vcpkg) and enable Testing within cmake.
So then for the
Testing/CmakLists.txt
we have defined the following:We copied over the
target_link_libraries
command from theusage
in the port description. Within oursometest.cc
we depend on some functionality from gmock:the
EXPECT_THAT
and theIsEmpty()
macro comes from thegmock-matchers.h
header.the full unittest in question:
So after we configure and build the project and then through visual studio we press
Test -> Run CTests for Performous
all is build correctly, we get a binary (performous_test.exe
) in the build directory and we can run it. But it says:No tests were found!!!
The test explorer also doesn't show any tests and runningctest
in the build directory also shows the same error message:no tests were found!!!
We were wondering what we're doing wrong... as it does work on linux
Edit
For what it's worth... If we remove the dependency of
gmock
and also remove it fromtarget_link_libraries
and make a unittest which doesn't depend on gmock it does get listed and works perfectly fine.We're using the latest release: 2022.07.25 In VS2022