CMakeTest

https://github.com/CMakePP/CMakeTest/workflows/CMakeTest%20Unit%20Tests/badge.svg https://github.com/CMakePP/CMakeTest/workflows/Build%20and%20Deploy%20Documentation/badge.svg

Unit tests are at the core of modern software development. As projects grow in size and scope, so do their needs for extensive testing. The same can be said for their build systems: as projects grow, their build processes become more complex, and as such, those processes become more prone to bugs and failures. Therefore, we believe that build system languages like CMake should have a robust testing framework, just like most application programming languages. CMakeTest is an implementation of such a framework for the CMake build system language.

CMakeTest is modeled after the Catch2 testing framework for C++. CMakeTest is a CMake module, written 100% in CMake. Tests are executed by the CTest infrastructure, minimizing friction for those already familiar with it.

Unit testing with CMakeTest relies on the use of ct_add_test and ct_add_section special declarations, followed by function blocks. Within these blocks users write their unit tests in native CMake; no need for ugly escapes or workarounds. The user then relies on assertions provided by CMakeTest to ensure that the program has the expected state. For example we can ensure that a CMake code sets a particular variable using ct_assert_equal. This looks like:

include(cmake_test/cmake_test)
ct_add_test(NAME "_first_test")
function(${_first_test})
    set(hello_world "Hello World!!!")
    ct_assert_equal(hello_world "Hello World!!!")
endfunction()

More examples and tutorials can be found in the documentation.

New users are recommended to start by visiting Installation, and then reading the Tutorials. Once one has read the tutorials,

Table of Contents