创建基于 CTest 的测试

无论使用何种测试框架,CTest 都能为基于 CMake 的项目执行测试。您可以在项目文件(通常是 CMakeLists.txt)中配置测试。基本上,你要为项目启用测试,并注册测试应用程序甚至特殊命令。

enable_testing()
add_test(NAME test_example COMMAND test_example)

在尝试将test_example 注册为测试之前,先将其添加为可执行文件。它可以是任何可执行命令,包括参数。

有关如何使用 CTest 的更多信息,请参阅使用 CTest 测试

另请参阅 如何:测试选择构建系统测试测试结果

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.