Skip to content

Avoid serialization for parameterized tests when running MTP+DisableAppDomain#7602

Draft
Youssef1313 wants to merge 3 commits intomainfrom
dev/ygerges/avoid-serialization
Draft

Avoid serialization for parameterized tests when running MTP+DisableAppDomain#7602
Youssef1313 wants to merge 3 commits intomainfrom
dev/ygerges/avoid-serialization

Conversation

@Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Mar 24, 2026

  • The VSTest condition complicates some stuff, but it avoids regressions for randomized tests. We could decide to take a breaking change for randomized tests and force users to fold them. But I'm avoiding this for now.
  • AppDomain check is missing currently. It's very needed as TestMethod.ActualData isn't serialized. So when we discover in an appdomain and run in another, the only way we have is serialization.

Copilot AI review requested due to automatic review settings March 24, 2026 14:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR threads an isMTP flag through MSTest discovery/execution paths so Microsoft.Testing.Platform (MTP) can alter how parameterized (data-driven) tests are handled—specifically aiming to avoid serializing unfolded ITestDataSource data when running under MTP with AppDomains disabled.

Changes:

  • Add isMTP plumbing from the MTP bridge into MSTest discover/run flows.
  • Pass isMTP through discovery components down to AssemblyEnumerator unfolding logic.
  • Update unit/integration tests to match new method signatures.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/UnitTests/MSTestAdapter.UnitTests/MSTestExecutorTests.cs Updates executor test calls to pass isMTP: false.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestExecutionManagerTests.cs Updates execution-manager tests for the new RunTestsAsync signature including isMTP.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Discovery/UnitTestDiscovererTests.cs Updates discoverer tests and overrides to accept isMTP.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Discovery/AssemblyEnumeratorWrapperTests.cs Updates wrapper tests to pass the new isMTP argument.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Discovery/AssemblyEnumeratorTests.cs Updates enumerator tests to call EnumerateAssembly(..., isMTP).
test/IntegrationTests/MSTest.IntegrationTests/Utilities/CLITestBase.discovery.cs Updates integration discovery helper to pass isMTP: false.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs Adds isMTP parameter to source-based run path and forwards it into discovery; also introduces an (unused) IsMicrosoftTestingPlatform property.
src/Adapter/MSTestAdapter.PlatformServices/Discovery/UnitTestDiscoverer.cs Adds isMTP parameter and forwards it to AssemblyEnumeratorWrapper.
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs Adds isMTP parameter and forwards it to AssemblyEnumerator.EnumerateAssembly.
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs Adds isMTP to unfolding pipeline and conditionally skips SerializedData generation for ITestDataSource rows.
src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestExecutor.cs Extends internal RunTestsAsync(sources, ...) to accept isMTP and pass through to TestExecutionManager.
src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs Extends internal DiscoverTests to accept isMTP and pass through to UnitTestDiscoverer.
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBridgedTestFramework.cs Calls adapter discover/run with isMTP: true when invoked from MTP.

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/avoid-serialization branch from 5140b34 to 87a5fd0 Compare March 24, 2026 16:59
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/avoid-serialization branch from 87a5fd0 to f51f810 Compare March 24, 2026 17:04
Copilot AI review requested due to automatic review settings March 24, 2026 17:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 24, 2026 18:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs:337

  • The new mustSerialize behavior (skipping DataSerializationHelper.Serialize when false) isn't covered by unit tests. Please add tests that exercise both paths (mustSerialize=true and mustSerialize=false) for ITestDataSource unfolding to ensure SerializedData is populated when required (AppDomain/serialization scenarios) and that execution can rely on ActualData when serialization is skipped.
                if (mustSerialize)
                {
                    discoveredTest.TestMethod.SerializedData = DataSerializationHelper.Serialize(d);
                }

                discoveredTest.TestMethod.ActualData = d;
                discoveredTest.TestMethod.TestCaseIndex = globalTestCaseIndex;
                discoveredTest.TestMethod.TestDataSourceIgnoreMessage = testDataSourceIgnoreMessage;
                discoveredTest.TestMethod.DataType = DynamicDataType.ITestDataSource;

Comment on lines +115 to +116
bool mustSerialize = !isMTP || isolationHost is TestSourceHost { UsesAppDomain: true };
return assemblyEnumerator.EnumerateAssembly(fullFilePath, mustSerialize);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

mustSerialize is now computed from isMTP and whether the isolation host uses AppDomains, but there are no tests covering this decision logic. Adding a targeted unit test (e.g., validating that when isMTP=true and AppDomains are disabled, discovery avoids serialization, and when AppDomains are enabled it still serializes) would help prevent regressions in the MTP + DisableAppDomain scenario this change is addressing.

Copilot uses AI. Check for mistakes.
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.

2 participants