Skip to content

Migrate dotnet-aot.Tests to MSTest.Sdk on MTP - #54908

Merged
Evangelink merged 3 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-dotnetaot-tests
Jun 22, 2026
Merged

Evangelink merged 3 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-dotnetaot-tests

Conversation

@Evangelink

Copy link
Copy Markdown
Member

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).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 20:23

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.

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.Tests to MSTest.Sdk and update project references from Microsoft.NET.TestFramework to Microsoft.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 process will 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

Comment thread test/dotnet-aot.Tests/AotIntegrationTests.cs
Comment thread test/dotnet-aot.Tests/NativeEntryPointTests.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink
Evangelink enabled auto-merge June 20, 2026 08:34
@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g #51530

@Evangelink
Evangelink merged commit ee837c0 into dotnet:main Jun 22, 2026
24 of 26 checks passed
@Evangelink
Evangelink deleted the evangelink/mstest-mtp-dotnetaot-tests branch June 22, 2026 16:43
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants