4.6 预期测试失败
准备工作
import sys
# simulate a failing test
sys.exit(1)实施步骤
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(recipe-06 LANGUAGES NONE) find_package(PythonInterp REQUIRED)enable_testing() add_test(example ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py) set_tests_properties(example PROPERTIES WILL_FAIL true)$ mkdir -p build $ cd build $ cmake .. $ cmake --build . $ ctest Test project /home/user/cmake-recipes/chapter-04/recipe-06/example/build Start 1: example 1/1 Test #1: example .......................... Passed 0.00 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.01 sec
工作原理
更多信息
Last updated