Create CTest Based Tests

CTest can execute tests for CMake based projects regardless of the test framework. You configure tests in the project file, usually, CMakeLists.txt. Basically, you enable testing for the project and register the test applications or even special commands.

enable_testing()
add_test(NAME test_example COMMAND test_example)

Add test_example as an executable before trying to register it as test. It may be any executable command including arguments.

For more information about how to use CTest, see Testing with CTest.

See also How To: Test, Select the build system, Testing, and Test Results.

© 2024 The Qt Company Ltd. 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.