A green managed test suite has always left a blind spot for teams shipping Native AOT applications. The test process runs with full reflection and a just-in-time compiler; the published executable runs with neither. Starting with MSTest 4.4, released September 3 on the .NET Blog, that gap narrows: test projects can now publish and run as Native AOT executables themselves.
Author Amaury Levé explains that source generation records test classes, attributes, and invocation delegates at compile time — before trimming removes unused code. The tests stay ordinary [TestClass] and [TestMethod] code; the generator changes the build and execution path, not the programming model.
The practical stakes are concrete. A managed test serializing a receipt with System.Text.Json passes because reflection discovers the type at runtime. In a trimmed Native AOT publish, that same path throws InvalidOperationException: Reflection-based serialization has been disabled for this application. The failure is useful — it catches a deployment problem before the product ships. The fix is a JSON source-generated context, which the System.Text.Json guidance documents.
MSTest’s first Native AOT preview arrived in April 2024. It proved the concept but had limited coverage. The 4.4 release moves generation into the open toolchain. During compilation the generator emits a registry of test classes, attribute data for supported members, delegates that construct and invoke tests, and references that preserve discovered classes when trimming runs.
The minimum project file is deliberately small:
<Project Sdk="MSTest.Sdk/4.4.0">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
MSTest.Sdk uses Microsoft Testing Platform by default. Setting PublishAot enables the native executable path. Projects still on VSTest should review the migration guidance — command-line arguments, CI integration, and .runsettings entries differ.
Publish for the same architecture as the application:
dotnet publish ./MyProject.Tests/MyProject.Tests.csproj \
-c Release -r linux-x64 -o ./artifacts/native-tests
./artifacts/native-tests/MyProject.Tests
Replace linux-x64 with your deployment RID (win-x64, osx-arm64). On Windows the executable is MyProject.Tests.exe.
The recommended pilot is narrow: keep the fast managed lane, add one native publish-and-run lane for a representative project, assert identical test counts and outcomes, and record native publish time separately. Expand only where the confidence justifies the CI cost. A project exercising serialization, dependency injection, configuration binding, or reflection-based plugins will surface deployment-only defects; arithmetic-style unit tests will not.
Not everything migrates. The MSTest documentation lists hard limits: a class that only inherits [TestClass] (analyzer MSTEST0069 flags this), inaccessible or file-local test classes, generic test methods, ref/out/in parameters, and [AssemblyFixtureProvider]. Some SDK integrations, MTP extensions, and CI reporters are unavailable in the Native AOT path; TRX and Code Coverage remain supported.
Levé wrote on the .NET Blog that source generation “avoids the assembly-wide Assembly.GetTypes() scan and reflective construction for supported tests” and that this “can reduce startup and discovery work” but doesn’t guarantee a faster end-to-end run — test execution, process startup, publishing, and remaining reflection can dominate. Production fidelity is the premise; performance is evidence, not the reason.

Image credit: Microsoft Learn
The Microsoft Testing Platform shift that MSTest 4.4 depends on mirrors the transition we covered in test reporting in Microsoft.Testing.Platform.
The rollout is deliberately reversible. If the native lane costs more than the confidence it adds, change its frequency, pick a more representative project, or stop the pilot without disrupting the managed suite. MSTest 4.4 gives teams a verified native publish path where the tests still look like MSTest but the executable behaves like the application you actually ship.
