cmake
Crear suites de prueba con CTest
Buscar..
Suite de prueba básica
# the usual boilerplate setup
cmake_minimum_required(2.8)
project(my_test_project
LANGUAGES CXX)
# tell CMake to use CTest extension
enable_testing()
# create an executable, which instantiates a runner from
# GoogleTest, Boost.Test, QtTest or whatever framework you use
add_executable(my_test
test_main.cpp)
# depending on the framework, you need to link to it
target_link_libraries(my_test
gtest_main)
# now register the executable with CTest
add_test(NAME my_test COMMAND my_test)
La macro enable_testing() hace mucha magia. En primer lugar, crea una test objetivo RUN_TESTS (para GNU make; RUN_TESTS for VS), que, cuando se ejecuta, ejecuta CTest .
La llamada a add_test() finalmente registra un ejecutable arbitrario con CTest , por lo que el ejecutable se ejecuta cuando llamamos al objetivo de test .
Ahora, genere el proyecto como de costumbre y finalmente ejecute el objetivo de prueba
| GNU Make | Estudio visual |
|---|---|
make test | cmake --build . --target RUN_TESTS |
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow