c++ - CTest 在简单的测试设置中找不到测试
问题描述
我正在向我的库中添加单元测试,但 ctest 总是说No tests were found!!!
.
在我的最高级别CMakeLists.txt
,我有以下内容
option(BUILD_TESTS OFF)
if (${BUILD_TESTS})
enable_testing()
add_subdirectory(tests)
endif()
和整数test/CMakeLists.txt
enable_testing()
project(test CXX)
add_executable(${PROJECT_NAME})
add_test(my_test ${PROJECT_NAME})
target_sources(
${PROJECT_NAME}
PRIVATE
test.cpp
)
我test.cpp
只是有一个简单的main()
bool test() {
return true;
}
int main(int, char**) {
return test() ? 0 : 1;
}
当我用cmake --build build/
它构建时,甚至会CTestTestfile.cmake
在构建目录中生成一个文件。但是当我现在跑步时,ctest -C Debug
我得到了No tests were found!!!
消息。
我怎样才能让这个基本测试起作用?
解决方案
推荐阅读
- javascript - 选择选择选项时使用 Javascript 添加 css 样式
- python - 使用 ftplib python 创建一个带有特殊字符的文件
- kubernetes - 使用 kubeadm 重置工作节点何时重新加入主节点
- paypal-ipn - 任何想法为什么我的 PayPal IPN 侦听器自发地开始抛出错误?
- mysql - mysql对象数组比较项目
- python - 条件语句不执行?
- powershell - 如何解决运行 Invoke-sqlcmd 命令以使用 Invoke-SQLCMD 和 Powershell 6 连接到 Azure Datawarehouse 的错误?
- mysql - 使用 JOIN 在重复值上查询 sql SUM 仅 1 个值
- c - 如何在 C 函数中分配三重指针的内存
- c - 这个空字符打印的输出是什么?