Skip to content

Fix Verify snapshot naming for xunit v3 compatibility#10052

Merged
MichaelSimons merged 2 commits intodotnet:mainfrom
MichaelSimons:fix-mtp-parameters
Mar 25, 2026
Merged

Fix Verify snapshot naming for xunit v3 compatibility#10052
MichaelSimons merged 2 commits intodotnet:mainfrom
MichaelSimons:fix-mtp-parameters

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

Summary

Verify.XunitV3 auto-detects [Theory] parameters from the xunit v3 test context and appends them to snapshot file paths. This breaks snapshot matching because TemplateVerifier already manages naming uniqueness via ScenarioName. It can also cause path-too-long errors, particularly in Helix where the directory structure is deeper.

This is a behavioral difference between Verify.Xunit (xunit v2) and Verify.XunitV3 (xunit v3) — the v2 package does not auto-append parameters, while the v3 package does regardless of test runner mode.

Fix

Switch from UseTypeName + UseMethodName to UseFileName, which replaces the entire type+method+parameters naming in a single call. This prevents Verify from appending auto-detected parameters.

UseFileName is the only Verify API that fully controls the output path — there is no more targeted API to disable parameter auto-appending. Snapshot file names remain functionally identical; the parameters previously managed via UseMethodName are now pre-baked into the file name string.

With MTP, Verify.XunitV3 auto-detects [Theory] parameters from the xUnit
test context and appends them to snapshot file paths. This breaks snapshot
matching because TemplateVerifier already manages naming uniqueness via
ScenarioName.

Switch from UseTypeName+UseMethodName to UseFileName which replaces the
entire type+method+parameters naming, preventing Verify from appending
auto-detected parameters regardless of test runner mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MichaelSimons MichaelSimons requested a review from a team as a code owner March 25, 2026 20:51
@MichaelSimons MichaelSimons merged commit 80848b3 into dotnet:main Mar 25, 2026
8 checks passed
@MichaelSimons MichaelSimons deleted the fix-mtp-parameters branch March 25, 2026 21:51
mmitche pushed a commit to dotnet/sdk that referenced this pull request Apr 2, 2026
…ing#10052)

## Summary

`Verify.XunitV3` auto-detects `[Theory]` parameters from the xunit v3
test context and appends them to snapshot file paths. This breaks
snapshot matching because TemplateVerifier already manages naming
uniqueness via `ScenarioName`. It can also cause path-too-long errors,
particularly in Helix where the directory structure is deeper.

This is a behavioral difference between `Verify.Xunit` (xunit v2) and
`Verify.XunitV3` (xunit v3) — the v2 package does not auto-append
parameters, while the v3 package does regardless of test runner mode.

## Fix

Switch from `UseTypeName` + `UseMethodName` to `UseFileName`, which
replaces the entire type+method+parameters naming in a single call. This
prevents Verify from appending auto-detected parameters.

`UseFileName` is the only Verify API that fully controls the output path
— there is no more targeted API to disable parameter auto-appending.
Snapshot file names remain functionally identical; the parameters
previously managed via `UseMethodName` are now pre-baked into the file
name string.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Commit migrated from dotnet/templating@80848b3
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.

3 participants