我正在使用 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
这不是很有帮助,因为我看不到哪个测试失败了。如果我从命令行手动运行 ctest,--verbose
我会从 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 单元测试?