How to get the current scenario name in HOOK_AFTER_SCENARIO or HOOK_BEFORE_SCENARIO?

オープン
#317 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
cpp
領域
testing

調査の方向性

HOOK_AFTER_SCENARIO() と current_test_info() の呼び出しから始め、cucumber-cpp がシナリオフックを GoogleTest のライフサイクルにどのように対応付けているかを調べます。null が想定された値かどうかを判断し、レポート用にシナリオ名を取得するサポートされた方法を文書化または特定できれば完了です。

索引モデルが 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時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cucumber/cucumber-cpp のほかの issue

cucumber/cucumber-cpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。