Skip to content

Support test filters across xUnit runners - #6013

Merged
max-charlamb merged 1 commit into
mainfrom
dev/max-charlamb/support-mixed-test-filters
Sep 8, 2026
Merged

Support test filters across xUnit runners#6013
max-charlamb merged 1 commit into
mainfrom
dev/max-charlamb/support-mixed-test-filters

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

  • Preserve the existing eng/build.ps1 -methodfilter and -classfilter interface.
  • Pass neutral filter properties into the test traversal.
  • Translate filters to -method/-class for the legacy xUnit runner and --filter-method/--filter-class for xUnit v3 using Microsoft Testing Platform.

This allows legacy SOS.UnitTests and the new SOS.Tests project to run in the same test invocation while using their respective command-line syntax.

Testing

  • Ran a filtered legacy SOS.UnitTests method through eng/build.ps1.
  • Ran one filtered xUnit v3 method through eng/build.ps1.
  • Ran four filtered xUnit v3 class tests through eng/build.ps1.

Note

This pull request description was generated with GitHub Copilot.

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
Copilot AI lite review requested due to automatic review settings September 8, 2026 19:31
@max-charlamb
max-charlamb requested a review from a team as a code owner September 8, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 TestRunnerAdditionalArguments injection from eng/build.ps1 with neutral MSBuild properties (DiagnosticsTestMethodFilter / DiagnosticsTestClassFilter).
  • Translates those neutral properties into runner-specific CLI arguments in src/tests/Directory.Build.targets (-method/-class vs --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: UseMicrosoftTestingPlatformRunner is not set anywhere in-repo, so this condition may silently choose the legacy -class syntax for XUnitV3 if the external targets don’t define that property. Prefer conditioning solely on TestRunnerName == 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.

Comment thread src/tests/Directory.Build.targets
@max-charlamb
max-charlamb enabled auto-merge (squash) September 8, 2026 20:38
@max-charlamb
max-charlamb merged commit 4487cc2 into main Sep 8, 2026
27 checks passed
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