Skip to content

fix(cucumberjs): use scenario line in testCaseId to prevent duplicate name collision#1502

Open
todti wants to merge 4 commits into
mainfrom
worktree-fix+cucumberjs-duplicate-scenario-names
Open

fix(cucumberjs): use scenario line in testCaseId to prevent duplicate name collision#1502
todti wants to merge 4 commits into
mainfrom
worktree-fix+cucumberjs-duplicate-scenario-names

Conversation

@todti
Copy link
Copy Markdown
Contributor

@todti todti commented May 29, 2026

Problem

Fixes #1387.

When two Scenario blocks in the same feature file share an identical name (but have different steps), the reporter computed the same testCaseId for both:

// before
const testCaseId = md5(`${fullNameBase}#${scenario?.name ?? pickle.name}`);

allure-report (the Java/HTML generator) deduplicates test results by testCaseId, so one of the two tests was silently dropped from the report — users saw N-1 tests instead of N. All other reporters (JSON, JUnit XML, HTML) were unaffected because they don't deduplicate.

Fix

Include scenario.location.line in the testCaseId hash. Two scenarios with the same name but on different lines now get distinct ids:

// after
const scenarioLine = scenario?.location?.line ?? "";
const testCaseId = md5(`${fullNameBase}#${scenario?.name ?? pickle.name}#${scenarioLine}`);

Scenario Outline rows are unaffected — all rows of one outline share the same Scenario Outline: line number, so they keep the same testCaseId. This is required for cross-run history tracking (you want to see the history of "row 1 of this outline" across multiple runs, not treat each run as a fresh test).

Breaking Change

testCaseId changes for every test in every feature file, because the hash input gains a #<line> suffix. Existing allure history tied to the old hash will be lost after upgrading — the first run after the upgrade will appear as a new test with no history.

_fallbackTestCaseId (the legacyTestCaseId used for allure2 → allure3 history migration) is unchanged, so the migration path from older allure versions is preserved.

Testing

Added duplicate-names.feature with two Scenario: same name blocks and a new test asserting they produce different testCaseId values. The existing test for Scenario Outline (should create same test case id for scenario outline tests with template name) continues to pass.

@github-actions github-actions Bot added the theme:cucumberjs CucumberJS related issue label May 29, 2026
…licate scenario names

When two `Scenario` blocks in the same feature file share an identical
name, the reporter was producing the same `testCaseId` for both.
allure-report deduplicates results by `testCaseId`, so one test was
silently dropped from the HTML report (N-1 tests shown instead of N).

Fix: include `scenario.location.line` in the md5 input for `testCaseId`.
Scenarios with the same name but different line numbers now get distinct
ids. Scenario Outline rows are unaffected — all rows of one outline share
the same line and therefore keep the same `testCaseId`, which is required
for cross-run history tracking.

BREAKING CHANGE: `testCaseId` changes for every test because the hash
input gains a `#<line>` suffix. Existing allure history tied to the old
hash will be lost after upgrading. `_fallbackTestCaseId`
(`legacyTestCaseId`) is unchanged to preserve the allure2→allure3
migration path.

Fixes #1387
@todti todti force-pushed the worktree-fix+cucumberjs-duplicate-scenario-names branch from 9af0581 to d1e5409 Compare May 29, 2026 15:47
@todti todti added type:bug Something isn't working theme:api Javascript API related issue theme:commons labels May 29, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

Allure Report Summary

Name Duration Stats New Flaky Retry Report
Allure JS – Pull request #1502 2h 28m Passed tests 4675   Broken tests 14 21 0 0 View

@github-actions github-actions Bot removed the theme:api Javascript API related issue label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:commons theme:cucumberjs CucumberJS related issue type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cucumber.js + playwright + allure shows N-1 tests in a report

1 participant