检测升压测试用例是否失败
Detect if boost test case failed
我想记录更多关于BOOST断言失败的数据。不确定这是否可能以及如何实现。
BOOST_AUTO_TEST_CASE( TestCase1 )
{
Data d;
d.fillUp(...);
d.operation1(...);
BOOST_CHECK(d == ...);
d.operation2(...);
BOOST_CHECK(d == ...);
...
if( /* anything above failed */)
{
log << d;
}
}
我对最后一种情况有意见。你能给我建议吗?我希望错误日志能够指示断言发生时Data对象中的条件。理想情况下,我希望它们被丢弃一次,即使测试用例中发生了多个断言。
我正在做以下事情来完成您想要的:
BOOST_CHECK_MESSAGE( current_test_passing(), d);
使用我刚刚添加到测试助手函数集合中的以下函数:
#include <boost/test/results_collector.hpp>
inline bool current_test_passing()
{
using namespace boost::unit_test;
test_case::id_t id = framework::current_test_case().p_id;
test_results rez = results_collector.results(id);
return rez.passed();
}
我发现这对与BOOST_REQIRE_结合的循环很有用……所以我可以快速查看许多检查中的任何一个失败的特定迭代,而不必在每个检查中添加"I="消息:
for (int i=0; i < HUGE_NUMBER; ++i) {
… many checks …
BOOST_REQUIRE_MESSAGE( current_test_passing(), "FAILED i=" << i );
}
相关文章:
- C ++回测问题:如何检查构造函数在假定失败时是否失败(给定输入的无效参数)
- C++编译器 g++.exe 无法编译简单的测试程序 - 确定 CXX 编译器是否工作失败
- 标准中是否有类似折叠的算法(或失败:提升)可用?
- C++标准是否保证失败的插入到关联容器中不会修改 rvalue-reference 参数?
- 为什么这C++检测T型是否具有空运算符(EDT const&)失败的特征?
- 是否保证标准提取运算符>>在失败时不会更改参数?
- C 标准是否指定在某些情况下,编译应在错误中失败
- std::tuple的实现是否允许在触发空类元素的派生到基转换时失败
- std::remove 和 std::remove_if 设计的稳定性是否失败
- 检查 QTextStream::运算符>>是否失败
- c++ sort() 函数对于<algorithm>整数数组的大小(元素数)>10^7 个元素的大输入是否失败?
- 为什么我们总是检查输入是否失败而不检查输出
- 如何在初始化的同一行检查流是否失败
- 如何检查“strcmp”是否失败
- 如何知道 sigsetjmp 或 siglongjmp 是否失败
- 检测升压测试用例是否失败
- 如何判断对变量的流提取是否失败
- 检查在vector的vector中搜索时std::find是否失败
- 如何检查数组中的输入是否失败
- 检查 QSqlQuery::addBindValue() 是否失败