[allure-behave] Steps from tag-excluded scenarios bleed into the next matching scenario's result when hide_excluded=true
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- python
- 領域
- testing-qa
調査の方向性
除外されたシナリオが破棄される listener.py の AllureListener.stop_scenario() から始め、hide_excluded=true を使用して、提供された behave コマンドで問題を再現します。生成された allure-results/*-result.json ファイルを調べます。該当するシナリオの結果にそのシナリオ自身のステップだけが含まれ、先行するタグ除外シナリオのステップが含まれていなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment
- allure-behave: 2.15.3
- allure-commons: (run
pip show allure-commons) - behave: 1.3.3
- Python: 3.12
Describe the Bug
When running behave with a tag filter (e.g. -t ETS-TC-372) and
-D AllureFormatter.hide_excluded=true, the Allure result JSON for the
matching scenario accumulates steps from all tag-excluded scenarios that
appeared before it in the same feature file.
For example: if Sample.feature has 12 scenarios before ETS-TC-372, and
those 12 scenarios collectively have 179 steps, the result JSON for ETS-TC-372
shows 227 steps (179 orphaned + 48 real) instead of 48.
Root Cause
Behave calls formatter.step(step) for every scenario — including
tag-excluded ones — because show_skipped=True by default
(run_scenario or show_skipped in Scenario.run()).
This schedules excluded scenario steps into AllureListener.self.steps (a
deque).
In stop_scenario(), excluded scenarios hit the should_drop_excluded=True
branch and call self.logger.drop_test(uuid) immediately, without ever
calling flush_steps() or clearing the deque. All accumulated steps remain
in the deque.
When the first matching scenario runs, its steps are appended to the
already-populated deque. match_step() pops from the front (FIFO), consuming
the orphaned steps and stamping them into the matching scenario's TestResult.
Reproduction Steps
- Create a feature file with 5+ scenarios where only the last one has
@target-tag. - Run:
behave -t target-tag my.feature \ --format allure_behave.formatter:AllureFormatter \ --outfile allure-results \ -D AllureFormatter.hide_excluded=true - Inspect allure-results/*-result.json — the step count will be
(sum of all excluded scenario steps) + (target scenario steps).
Expected Behaviour
The result JSON for the matching scenario should contain only its own
steps.
Fix
In AllureListener.stop_scenario(), clear the deque before dropping the
test so orphaned steps do not leak into the next scenario:
listener.py — stop_scenario()
if should_drop_skipped_by_option or should_drop_excluded:
self.steps.clear() # ← add this line
self.logger.drop_test(self.current_scenario_uuid)
This one-line fix prevents accumulated steps from tag-excluded scenarios
bleeding into any subsequent scenario's result.
- 主要言語
- Python
- スター
- 815
- フォーク
- 260
- 平均マージ
- 9時間 12分
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
allure-framework/allure-python のほかの issue
-
Added Categories オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
allure-framework/allure-python#918 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
allure-framework/allure-python#903 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
allure-framework/allure-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100