Steps throwing exceptions not reported as an error (Boost.Test)

未关闭
#222 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
testing

调研方向

定位 BoostDriver 对 runWithMasterSuite() 的调用,并检查 unit_test_monitor.ipp,其中会捕获异常并将其报告给 observer。检查 driver 如何确定 step 是否成功,并将其与 Boost.Test results_collector 的输出进行比较。当抛出异常的 step 被报告为失败而不是成功,并且失败详情对 cucumber-cpp 可用时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

Summary

We encountered the issue that step definitions which throw an exception are reported as passed, when using the Boost.Test framework and cucumber-cpp.

Expected Behavior

Our expectation was that a step which throws an exception (for whatever reason) should be reported as a failed step by cucumber-cpp.

Current Behavior

The step is reported as passed. The rest of the step definition after the exception gets thrown, doesn't get executed.

Possible Solution

Not familiar with Boost.Test nor cucumber-cpp source code, but while debugging this, I noticed the following:
The exception is caught by unit_test_monitor_t::execute_and_translate(...) in unit_test_monitor.ipp and gets reported to test observers.
However, the BoostDriver only considers the test log for the decision to rate a step as success or failure, but exceptions don't show up in this log for some reason.
We could successfully trigger a failed step by adding something along the following lines after runWithMasterSuite() (needs #include <boost/test/results_collector.hpp>):

auto results = ::boost::unit_test::results_collector.results(testCase->p_id);
if (!results.passed())
{
  std::string description = "Test aborted/failed with result code " + std::to_string(results.result_code());
  return InvokeResult::failure(description.c_str());
}
主要语言
C++
星标
330
派生
142
平均合并
2 天 8 小时
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cucumber/cucumber-cpp 的其他 Issue

查看 cucumber/cucumber-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。