Support test filters across xUnit runners - #6013
Conversation
Keep the build script's method and class filter options while translating them to the command-line syntax required by each test runner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b2ca30d-742d-402c-8ba5-afec8b6d69a1
There was a problem hiding this comment.
🟡 Changes recommended
The new MSBuild condition relies on UseMicrosoftTestingPlatformRunner, which is not set anywhere in-repo and could cause xUnit v3 filtering to silently fall back to legacy arguments depending on external target behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the existing eng/build.ps1 -methodfilter / -classfilter interface so it can filter tests correctly across both the legacy xUnit console runner and the newer xUnit v3 runner (Microsoft Testing Platform) during a single traversal-based test invocation.
Changes:
- Replaces direct
TestRunnerAdditionalArgumentsinjection fromeng/build.ps1with neutral MSBuild properties (DiagnosticsTestMethodFilter/DiagnosticsTestClassFilter). - Translates those neutral properties into runner-specific CLI arguments in
src/tests/Directory.Build.targets(-method/-classvs--filter-method/--filter-class).
File summaries
| File | Description |
|---|---|
| src/tests/Directory.Build.targets | Adds translation from neutral filter properties into runner-specific arguments for legacy xUnit vs xUnit v3 (MTP). |
| eng/build.ps1 | Preserves the existing script interface but now passes neutral filter properties into MSBuild instead of runner-specific args. |
Review details
Suppressed comments (1)
src/tests/Directory.Build.targets:12
- Same as the method-filter block:
UseMicrosoftTestingPlatformRunneris not set anywhere in-repo, so this condition may silently choose the legacy-classsyntax for XUnitV3 if the external targets don’t define that property. Prefer conditioning solely onTestRunnerName == XUnitV3(or define a default when using the XUnitV3 runner).
<PropertyGroup Condition="'$(DiagnosticsTestClassFilter)' != ''">
<TestRunnerAdditionalArguments Condition="'$(TestRunnerName)' == 'XUnitV3' and '$(UseMicrosoftTestingPlatformRunner)' == 'true'">$(TestRunnerAdditionalArguments) --filter-class $(DiagnosticsTestClassFilter)</TestRunnerAdditionalArguments>
<TestRunnerAdditionalArguments Condition="'$(TestRunnerName)' != 'XUnitV3' or '$(UseMicrosoftTestingPlatformRunner)' != 'true'">$(TestRunnerAdditionalArguments) -class $(DiagnosticsTestClassFilter)</TestRunnerAdditionalArguments>
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Summary
eng/build.ps1-methodfilterand-classfilterinterface.-method/-classfor the legacy xUnit runner and--filter-method/--filter-classfor xUnit v3 using Microsoft Testing Platform.This allows legacy
SOS.UnitTestsand the newSOS.Testsproject to run in the same test invocation while using their respective command-line syntax.Testing
SOS.UnitTestsmethod througheng/build.ps1.eng/build.ps1.eng/build.ps1.Note
This pull request description was generated with GitHub Copilot.