Skip to content

fix: expose scenario name in $test binding#2705

Open
Ayush-Patel-56 wants to merge 2 commits into
kyverno:mainfrom
Ayush-Patel-56:fix/scenario-name-in-test-binding
Open

fix: expose scenario name in $test binding#2705
Ayush-Patel-56 wants to merge 2 commits into
kyverno:mainfrom
Ayush-Patel-56:fix/scenario-name-in-test-binding

Conversation

@Ayush-Patel-56

Copy link
Copy Markdown
Contributor

Explanation

Scenario names were silently ignored at runtime - defining a name on a scenario had no effect beyond the YAML schema. This fix makes the name available as $test.ScenarioName so it can be referenced in bindings, scripts, and expressions.

Related issue

Fixes #2614

Proposed Changes

  • Added ScenarioName string to TestInfo in pkg/runner/info.go
  • Passed scenarioName into setupTestContext so it gets populated in the $test binding

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

Before this fix, $test.ScenarioName was always an empty string even when name was set on a scenario:

{"Id":1,"ScenarioId":1,"ScenarioName":"","Metadata":{"name":"scenario-name-test"}}

@Ayush-Patel-56 Ayush-Patel-56 requested a review from a team as a code owner May 4, 2026 11:20
@Ayush-Patel-56 Ayush-Patel-56 changed the title Fix/scenario name in test binding fix: expose scenario name in $test binding May 4, 2026
@codecov

codecov Bot commented May 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.71%. Comparing base (d253bff) to head (ba6e4bf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2705   +/-   ##
=======================================
  Coverage   67.70%   67.71%           
=======================================
  Files         149      149           
  Lines        5757     5758    +1     
=======================================
+ Hits         3898     3899    +1     
  Misses       1599     1599           
  Partials      260      260           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ayush-Patel-56 Ayush-Patel-56 force-pushed the fix/scenario-name-in-test-binding branch 2 times, most recently from 9f54cbd to 6708f7a Compare May 6, 2026 14:20
Signed-off-by: Ayush Patel <ayushpatel2731@gmail.com>
Signed-off-by: Ayush Patel <ayushpatel2731@gmail.com>
@Ayush-Patel-56 Ayush-Patel-56 force-pushed the fix/scenario-name-in-test-binding branch from 6708f7a to ba6e4bf Compare May 13, 2026 13:25
@eddycharly

Copy link
Copy Markdown
Member

Coming back to this, I wonder why we don't have a ScenarioInfo struct 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] scenario name not exposed in bindings

2 participants