How to get the current scenario name in HOOK_AFTER_SCENARIO or HOOK_BEFORE_SCENARIO?
还没有人认领这个 Issue。
评估
调研方向
从 HOOK_AFTER_SCENARIO() 和 current_test_info() 调用入手,然后检查 cucumber-cpp 如何将 scenario hook 映射到 GoogleTest 生命周期。完成标准是确定 null 是否为预期值,并记录或确认获取 scenario 名称用于报告的受支持方式。
由索引模型根据 Issue 内容生成。
描述
🤔 What's the problem you've observed?
current_test_info() is null in HOOK_AFTER_SCENARIO
Hi,
I'm using cucumber-cpp and noticed that ::testing::UnitTest::GetInstance()->current_test_info() returns nullptr inside HOOK_AFTER_SCENARIO().
Example:
HOOK_AFTER_SCENARIO()
{
const auto* test_info =
::testing::UnitTest::GetInstance()->current_test_info();
if (test_info) {
std::cout << test_info->name() << std::endl;
} else {
std::cout << "test_info is null" << std::endl;
}
}
The hook is executed correctly, but test_info is always nullptr.
My goal is to obtain the current scenario/test name during HOOK_AFTER_SCENARIO() for reporting purposes.
Is this expected behavior?
If so, could you please advise what the recommended way is to retrieve the current scenario name from within HOOK_AFTER_SCENARIO()?
Thanks!
✨ Do you have a proposal for making it better?
No response
📚 Any additional context?
No response
- 主要语言
- C++
- 星标
- 330
- 派生
- 142
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cucumber/cucumber-cpp 的其他 Issue
-
难度 5/5 一周以上 新手友好度 20/100
cucumber/cucumber-cpp#313 · 9 条评论 ·
-
Authorize hyphen "-" for Tag可能重新可做 @ursfassler 于 399 天前认领,目前没有进行中的 PR。 未关闭bug
cucumber/cucumber-cpp#312 · 4 条评论 · 已指派 1 人 ·
-
feature
难度 4/5 3-5 天 新手友好度 35/100
cucumber/cucumber-cpp#304 · 2 条评论 ·
-
help
难度 4/5 3-5 天 新手友好度 25/100
cucumber/cucumber-cpp#302 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
cucumber/cucumber-cpp#297 · 13 条评论 ·
查看 cucumber/cucumber-cpp 的全部 Issue
相似的 Issue
-
Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)未关闭
难度 2/5 1-3 小时 新手友好度 73/100
cloudflare/workerd#8963 ·
维护者通常 1 天内回复
-
Android Bug Core Drape
难度 2/5 1-3 小时 新手友好度 77/100
organicmaps/organicmaps#14449 ·
维护者通常 1 天内回复
-
comp-codecs
难度 2/5 1-3 小时 新手友好度 84/100
ClickHouse/ClickHouse#135159 ·
维护者通常 1 天内回复
-
category:port-update
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 2 天内回复
-
difficulty:easy func:python os:windows prio:high type:bug
难度 2/5 1-3 小时 新手友好度 78/100
NatronGitHub/Natron#2029 ·
维护者通常 1 天内回复