Skip to content

Move test-case filter parsing to adapter boundary (Phase 6d-1)#9591

Draft
Evangelink wants to merge 1 commit into
dev/amauryleve/vstest-decoupling-settingsfrom
dev/amauryleve/vstest-decoupling-filter
Draft

Move test-case filter parsing to adapter boundary (Phase 6d-1)#9591
Evangelink wants to merge 1 commit into
dev/amauryleve/vstest-decoupling-settingsfrom
dev/amauryleve/vstest-decoupling-filter

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Phase 6d-1 of the PlatformServices platform-agnostic initiative

Part of removing the VSTest object model (Microsoft.TestPlatform.ObjectModel) dependency from MSTestAdapter.PlatformServices.

This phase moves the test-case filter parsing to the adapter boundary. TestMethodFilter (which parses the VSTest ITestCaseFilterExpression from IRunContext/IDiscoveryContext.GetTestCaseFilter) moves out of PlatformServices into MSTest.TestAdapter, and the engine/discoverer receive an injected neutral ITestElementFilter via a new ITestElementFilterProvider abstraction.

What changed

  • New ITestElementFilterProvider (PlatformServices.Interface): ITestElementFilter? GetTestElementFilter(IAdapterMessageLogger, out bool filterHasError).
  • Moved TestMethodFilter (+ nested TestElementFilter) → MSTest.TestAdapter (class body byte-identical); added a boundary TestElementFilterProvider that closes over the VSTest context.
  • The boundary (MSTestExecutor, MSTestDiscoverer — which the MTP MSTestBridgedTestFramework also routes through) builds new TestElementFilterProvider(context) and injects it into TestExecutionManager.RunTestsAsync/ExecuteTestsAsync and UnitTestDiscoverer.DiscoverTests.
  • The engine/discoverer invoke the provider at the exact same call sites they previously built the filter (per source), so parse-error reporting keeps the same timing and per-source count.

No behavior change

TestElementFilter.Matches still does element.ToTestCase() (byte-for-byte; the #9568 no-round-trip optimization is deferred as its own follow-up). This removes ITestCaseFilterExpression / GetTestCaseFilter / MatchTestCase / the VSTest filter TestProperty set from PlatformServices code. IRunContext/IDiscoveryContext remain only for deployment + settings extraction (removed in 6d-2).

Verification

  • Full build green across all TFMs (net462, net8.0, net9.0, UWP, WinUI).
  • MSTestAdapter.PlatformServices.UnitTests: 897 (net8.0) / 935 (net462); MSTestAdapter.UnitTests: 21; MSTest.IntegrationTests: 47 pass / 1 skip — including TestCaseFilteringTests, the out-of-proc filter regression net.
  • Expert MSTest/MTP reviewer: no material findings; definitive byte-for-byte verdict on the per-source parse-error timing/count and the null-provider equivalence.

Base / stacking

Remaining work

Move TestMethodFilter (and its nested TestElementFilter) out of MSTestAdapter.PlatformServices
up into MSTest.TestAdapter, and inject the neutral ITestElementFilter into the engine and
discoverer via a new ITestElementFilterProvider abstraction.

- New neutral ITestElementFilterProvider (PlatformServices.Interface): the boundary builds it
  (TestElementFilterProvider, closing over the VSTest IRunContext/IDiscoveryContext) and passes it
  into TestExecutionManager.RunTestsAsync/ExecuteTestsAsync and UnitTestDiscoverer.DiscoverTests.
- The engine/discoverer invoke the provider at the EXACT points they previously built the filter
  (per source), so filter parse-error reporting keeps the same timing and per-source semantics;
  TestElementFilter.Matches still does element.ToTestCase() (byte-for-byte; #9568 deferred).
- This removes ITestCaseFilterExpression / GetTestCaseFilter / MatchTestCase / the VSTest
  TestProperty filter set from PlatformServices code. IRunContext/IDiscoveryContext remain only for
  deployment + settings extraction (removed in a follow-up).

No behavior change: filtered set/order and the discovery/execution filterHasError bail-out are
identical; TestCaseFilteringTests (out-of-proc filter regression net) stays green.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink changed the base branch from dev/amauryleve/vstest-decoupling-base to dev/amauryleve/vstest-decoupling-settings July 3, 2026 17:20
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.

1 participant