Avoid serialization for parameterized tests when running MTP+DisableAppDomain#7602
Avoid serialization for parameterized tests when running MTP+DisableAppDomain#7602Youssef1313 wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
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
isMTPplumbing from the MTP bridge into MSTest discover/run flows. - Pass
isMTPthrough discovery components down toAssemblyEnumeratorunfolding 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. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs
Outdated
Show resolved
Hide resolved
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs
Outdated
Show resolved
Hide resolved
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs
Outdated
Show resolved
Hide resolved
5140b34 to
87a5fd0
Compare
87a5fd0 to
f51f810
Compare
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
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
mustSerializebehavior (skippingDataSerializationHelper.Serializewhen false) isn't covered by unit tests. Please add tests that exercise both paths (mustSerialize=true and mustSerialize=false) for ITestDataSource unfolding to ensureSerializedDatais populated when required (AppDomain/serialization scenarios) and that execution can rely onActualDatawhen 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;
| bool mustSerialize = !isMTP || isolationHost is TestSourceHost { UsesAppDomain: true }; | ||
| return assemblyEnumerator.EnumerateAssembly(fullFilePath, mustSerialize); |
There was a problem hiding this comment.
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.
TestMethod.ActualDataisn't serialized. So when we discover in an appdomain and run in another, the only way we have is serialization.