简体   繁体   English

GoogleTest测试无法开始

[英]GoogleTest tests don't start

It's my test fixture: https://github.com/patrykbajos/ZinotEngine/blob/master/src/tests/core/MapResMgrTest.cpp . 这是我的测试装置: https : //github.com/patrykbajos/ZinotEngine/blob/master/src/tests/core/MapResMgrTest.cpp My CMake file for this executable: https://github.com/patrykbajos/ZinotEngine/blob/master/ZinotEngine.cmake and CMakeLists for all executables https://github.com/patrykbajos/ZinotEngine/blob/master/CMakeLists.txt . 我的此可执行文件的CMake文件: https : //github.com/patrykbajos/ZinotEngine/blob/master/ZinotEngine.cmake和所有可执行文件的CMakeLists https://github.com/patrykbajos/ZinotEngine/blob/master/CMakeLists.txt I've compiled gtest from sources in apt-get package libgtest-dev on Ubuntu. 我已经从Ubuntu上的apt-get软件包libgtest-dev中的源编译了gtest。 Next I copied *.so files to /usr/lib and installed libgtest-dev packege because include files. 接下来,我将* .so文件复制到/ usr / lib并安装了libgtest-dev packege,因为其中包含文件。 I think that my test fixture is right. 我认为我的测试装置是正确的。 There are no compilation errors. 没有编译错误。 My exec runs an usually and displays: 我的执行程序通常运行并显示:

/home/patryk/ClionProjects/BennuEngine/bin/Debug/ZinotEngine
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[  PASSED  ] 0 tests.
Hello world!!!
Process finished with exit code 0 

I've added some lines to CMake file but I think that it doesn't add *.cpp files containing tests to build executable. 我在CMake文件中添加了几行,但我认为它没有添加* .cpp文件,其中包含用于构建可执行文件的测试。 Here's these lines: 以下是这些行:

# Sources
file(GLOB_RECURSE ZINOTENGINE_SRC "src/zinot/core/*.c" "src/zinot/core/*.cpp")
file(GLOB_RECURSE ZINOTENGINETESTS_SRC "src/tests/*.cpp")

if (CMAKE_BUILD_TYPE EQUAL "Debug")
    message("Debug << dodawanie testów.")
    set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC} ${ZINOTENGINETESTS_SRC}")
endif ()

# Binary
add_executable(ZinotEngine ${ZINOTENGINE_SRC})

It's my whole repository of code: https://github.com/patrykbajos/ZinotEngine . 这是我的整个代码库: https : //github.com/patrykbajos/ZinotEngine

PS. PS。 I'm compiling my project by CLion with Configuration: Debug on Build All . 我正在通过CLion使用Configuration: Debug编译我的项目Configuration: DebugBuild AllConfiguration: Debug

I've found the bug. 我发现了这个错误。 It was in: 它是在:

if (CMAKE_BUILD_TYPE EQUAL "Debug")
    message("Debug << dodawanie testów.")
    set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC} ${ZINOTENGINETESTS_SRC}")
endif ()

It should be: 它应该是:

if (CMAKE_BUILD_TYPE MATCHES Debug)
    #message("Debug << dodawanie testów.")
    set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC};${ZINOTENGINETESTS_SRC}")
endif ()

I though that separator of source files is space but it's semicolon. 我虽然源文件的分隔符是空格,但它是分号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM