Migrate dotnet-aot.Tests to MSTest.Sdk on MTP - #54908
Merged
Evangelink merged 3 commits intoJun 22, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates test/dotnet-aot.Tests from xUnit to MSTest.Sdk running on Microsoft.Testing.Platform (MTP), including support for publishing and executing the test assembly as a NativeAOT binary.
Changes:
- Switch
dotnet-aot.TeststoMSTest.Sdkand update project references fromMicrosoft.NET.TestFrameworktoMicrosoft.NET.TestFramework.MSTest. - Convert test attributes/assertions from xUnit to MSTest equivalents, including DataRow-based parameterized tests and
TestContext-based logging. - Add assembly-level non-parallelization and override default MSTest method-level parallel settings for this project.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet-aot.Tests/dotnet-aot.Tests.csproj | Switches project to MSTest.Sdk, updates test framework reference, and disables MSTest method-level parallelization for this assembly. |
| test/dotnet-aot.Tests/AssemblyInfo.cs | Replaces xUnit collection-parallelization config with MSTest [assembly: DoNotParallelize]. |
| test/dotnet-aot.Tests/NativeEntryPointTests.cs | Converts unit tests for NativeEntryPoint.ExecuteCore to MSTest attributes/assertions. |
| test/dotnet-aot.Tests/DotnetRootResolverTests.cs | Converts resolver tests to MSTest attributes/assertions. |
| test/dotnet-aot.Tests/AotParserTests.cs | Converts parser tests to MSTest, including local replacement for Record.Exception. |
| test/dotnet-aot.Tests/AotIntegrationTests.cs | Converts end-to-end “dn” integration tests to MSTest, adds TestContext output helper and cancellation token usage. |
Copilot's findings
Comments suppressed due to low confidence (1)
test/dotnet-aot.Tests/AotIntegrationTests.cs:90
- On timeout this returns while stdout/stderr read tasks are still running, and the
using var processwill dispose the underlying streams. That can lead to background read tasks faulting/unobserved and can also leave child processes running. Consider killing the entire process tree, waiting for exit, and ensuring the read tasks complete before returning.
if (!process.WaitForExit(timeoutMs))
{
process.Kill();
return (-1, "", "[TIMEOUT]");
}
- Files reviewed: 6/6 changed files
- Comments generated: 2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink
enabled auto-merge
June 20, 2026 08:34
Member
Author
|
/ba-g #51530 |
JeremyKuhne
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the ongoing xUnit -> MSTest.Sdk (MTP) test migration of the .NET SDK test suite. Migrates the last remaining xUnit test project, dotnet-aot.Tests, to MSTest.Sdk on Microsoft.Testing.Platform.
This project has a NativeAOT publish mode (dotnet publish -p:PublishAotTests=true) that previously relied on the xUnit v3 AOT packages (xunit.v3.core.aot.mtp-v2) and the eng/XUnitV3/XUnitV3.targets machinery. That is replaced by MSTest.Sdk on MTP, whose source generator performs reflection-free test discovery and is NativeAOT-compatible, so the UseXUnitAotPackages property, the UseMicrosoftTestingPlatformRunner override, and the transitive xUnit AOT package exclusions are all removed.
Standard transformations: Microsoft.NET.Sdk -> MSTest.Sdk, the TestFramework project reference -> Microsoft.NET.TestFramework.MSTest, [Fact] -> [TestMethod], xUnit asserts -> MSTest (Empty -> IsEmpty, Equal -> AreEqual, Contains -> FluentAssertions Should().Contain, Skip -> Inconclusive, IsNotType -> an is-type check, Record.Exception -> a local try/catch helper), the AOT [Trait] category -> [TestCategory], CollectionBehavior(DisableTestParallelization = true) -> [assembly: DoNotParallelize] plus an empty MSTestParallelizeScope, and ITestOutputHelper constructor injection replaced with a TestContext-backed output helper.
Verified: the regular build is clean, and dotnet publish -r win-x64 -p:PublishAotTests=true produces a native dotnet-aot.Tests.exe that discovers and lists all tests (the MSTest source generator works under NativeAOT).