我正在使用CMake构建我的项目。我已经添加了一个使用Boost单元测试框架的单元测试二进制文件。这个二进制文件包含所有的单元测试。我已经将该二进制文件添加到CTest中运行:
ADD_EXECUTABLE( tftest test-main.cpp )
ENABLE_TESTING()
ADD_TEST( UnitTests tftest)
但是在 Visual Studio 中构建输出仅显示运行 CTest 的结果:
Start 1: UnitTests
1/1 Test #1: UnitTests ................***Failed 0.05 sec
0% tests passed, 1 tests failed out of 1
这并不是很有帮助,因为我无法看到哪个测试失败了。如果我从命令行手动运行--verbose
ctest,我将得到一个来自Boost单元测试的输出,告诉我实际上失败了什么:
1: Test command: tftest.exe
1: Test timeout computed to be: 9.99988e+006
1: Running 4 test cases...
1: test-main.cpp(20): error in "sanity_check3": check 1 == 2 failed
1:
1: *** 1 failure detected in test suite "Master Test Suite"
1/1 Test #1: UnitTests ................***Failed 0.00 sec
那么,我需要在CMakeLists.txt中做哪些更改才能使CTest始终以--verbose
运行?是否有更好的方法来使用CMake / CTest进行Boost单元测试?