【发布时间】:2021-02-13 12:48:12
【问题描述】:
Catch2 和Boost.Test 为编写单元测试提供了类似的功能。 对于某个项目,我必须使用 Boost.Test 而不是 Catch2。 我遇到的问题是两者都使用不同的格式输出。
例如,Catch2 会说这是失败
test.cpp:9
(参见下面的示例)。 但是 Boost.Test 会说
test.cpp(9): error in ....
这种格式不允许我的编辑器将输出识别为源位置。
有没有办法让 Boost.Test 将源位置输出为file.ext:lineno 而不是file.ext(lineno)?
这是 Catch2 的典型输出
----------------------------------------------
Testing Binary Search
----------------------------------------------
test.cpp:9
..............................................test.cpp:18: FAILED:
REQUIRE( binary_search(arr, 176) == 0 )
with expansion:
-1 == 0==============================================
test cases: 1 | 1 failed
assertions: 5 | 4 passed | 1 failed
这是 Boost.Test 的典型输出
Running 7 test cases...
./layout.hpp(764): error: in "layout_to_offset_1d_nontrivial": check L[3] == &B[3] - base(B) has failed [3 != 6]
Running 7 test cases...
./.././detail/layout.hpp(764): error: in "layout_to_offset_1d_nontrivial": check L[3] == &B[3] - base(B) has failed [3 != 6]
*** 1 failure is detected in the test module "C++ Unit Tests for Multi layout"
【问题讨论】:
标签: c++ unit-testing boost-test output-formatting catch2