[allure-behave] Steps from tag-excluded scenarios bleed into the next matching scenario's result when hide_excluded=true

オープン 初心者向け
#902 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
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

  1. Create a feature file with 5+ scenarios where only the last one has
    @target-tag.
  2. Run:
    behave -t target-tag my.feature \
      --format allure_behave.formatter:AllureFormatter \
      --outfile allure-results \
      -D AllureFormatter.hide_excluded=true
    
  3. 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

allure-framework/allure-python のほかの issue

allure-framework/allure-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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