Repository navigation
Add Microsoft.NET.TestFramework.MSTest infra to onboard the test suite to MSTest - #54769
Merged
Evangelink merged 3 commits intoJun 16, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Microsoft.NET.TestFramework.MSTest infrastructure project to enable migrating dotnet/sdk test projects from xUnit to MSTest (MTP) by link-sharing the runner-agnostic portions of the existing Microsoft.NET.TestFramework while providing MSTest-specific replacements (output abstraction, base test class, logger factory).
Changes:
- Added
test/Microsoft.NET.TestFramework.MSTestproject that link-shares most sources from the legacy framework and supplies MSTest-specific implementations (ITestOutputHelper,TestContextOutputHelper,SdkTest,TestLoggerFactory). - Added
InternalsVisibleToentries so the new MSTest framework can access required internals used by link-shared helpers. - Registered the new project in
sdk.slnx.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework.MSTest/TestLoggerFactory.cs | MSTest logger factory producing ILogger instances backed by test output and console logging. |
| test/Microsoft.NET.TestFramework.MSTest/TestContextOutputHelper.cs | MSTest TestContext-backed implementation of the shared ITestOutputHelper abstraction. |
| test/Microsoft.NET.TestFramework.MSTest/SdkTest.cs | MSTest base class for SDK tests using TestContext rather than ctor injection. |
| test/Microsoft.NET.TestFramework.MSTest/Microsoft.NET.TestFramework.MSTest.csproj | New project file configuring link-sharing of runner-agnostic sources and MSTest dependencies. |
| test/Microsoft.NET.TestFramework.MSTest/ITestOutputHelper.cs | Local ITestOutputHelper interface to keep shared sources runner-agnostic. |
| src/Cli/Microsoft.DotNet.InternalAbstractions/Properties/Properties.cs | Grants internals access to the new MSTest framework assembly. |
| src/Cli/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs | Grants internals access to the new MSTest framework assembly. |
| sdk.slnx | Adds the new MSTest framework project to the solution. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 2
Evangelink
enabled auto-merge (squash)
June 15, 2026 12:07
…cation)
Introduces an MSTest-flavored counterpart of the xUnit-coupled
Microsoft.NET.TestFramework so SDK test projects can migrate to MSTest on
Microsoft.Testing.Platform. This is the foundational unlock for onboarding the
whole test suite (~53 projects reference the shared framework).
The xUnit coupling of the legacy framework is concentrated in ~17 of ~99 files
(the Attributes/* discovery attributes and two IMessageSink-based logger
bridges). The remaining ~82 runner-agnostic files reference the test output sink
only through the unqualified name ITestOutputHelper. This project therefore
LINK-SHARES those agnostic sources (zero duplication) and supplies the
MSTest-specific pieces locally:
* ITestOutputHelper - own interface (shape-identical to xUnit v3's) so the
shared sources bind to it instead of Xunit.ITestOutputHelper
* TestContextOutputHelper - MSTest TestContext-backed implementation
* SdkTest - MSTest base class (TestContext property instead of
constructor injection)
* TestLoggerFactory - MSTest logger factory (reuses the shared XunitLoggerProvider)
The namespace is kept as Microsoft.NET.TestFramework so that, once every consumer
has migrated, the legacy project can be deleted and this one renamed with no
source churn.
Also grants InternalsVisibleTo to the new assembly from
Microsoft.DotNet.Cli.Utils and Microsoft.DotNet.InternalAbstractions (the
link-shared Mock/* helpers use their internals), and registers the project in
sdk.slnx.
Builds clean on net11.0 and net472.
Co-authored-by: Copilot <[email protected]>
Switches the project from plain Microsoft.NET.Sdk + a MSTest.TestFramework PackageReference (VersionOverride hack) to Sdk="MSTest.Sdk" with IsTestApplication=false. Per MSTest.Sdk's ClassicEngine.targets, the "Core" MSTest.TestFramework reference is unconditional, while MSTest.TestAdapter, the MSTest runner, Microsoft.Testing.Platform and the testing extensions are gated on IsTestApplication=='true'. So a test *library* gets the framework (with its version kept in sync with the SDK) and none of the test-application machinery. Also drops the now-redundant AwesomeAssertions PackageReference and FluentAssertions global using: UsingMSTestSdk=true (set by MSTest.Sdk) makes test/Directory.Build.targets provide both. Verified: builds clean on net11.0 and net472; output contains no TestAdapter / Microsoft.Testing.Platform / extensions assemblies. Co-authored-by: Copilot <[email protected]>
- TestLoggerFactory: add a parameterless constructor (chaining to the TestContext? overload) to preserve the legacy 'new TestLoggerFactory()' usage and minimize source churn when consumers migrate; drop the unnecessary cast when chaining the TestContext? overload. - TestContextOutputHelper: correct the misleading comment that claimed TestContext only exposes WriteLine - it exposes Write (no trailing newline), which is what the partial-write path intentionally uses. Co-authored-by: Copilot <[email protected]>
Evangelink
force-pushed
the
evangelink/mstest-test-framework-infra
branch
from
June 16, 2026 07:04
416e47c to
60eecf8
Compare
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
JeremyKuhne
approved these changes
Jun 16, 2026
This was referenced Jun 24, 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.
Goal
Foundational infrastructure to onboard the entire dotnet/sdk test suite to MSTest on Microsoft.Testing.Platform (MTP).
The blocker to a full migration is the shared
Microsoft.NET.TestFrameworkproject: it is coupled to xUnit and is referenced by ~53 test projects, so none of them can move to MSTest until the framework offers an MSTest-compatible surface.Key insight: the xUnit coupling is shallow
The coupling is concentrated in ~17 of ~99 files:
Attributes/*discovery attributes (PlatformSpecificFact,*MSBuildOnly*,Requires*, …), andIMessageSink-based logger bridges (SharedTestOutputHelper.cs,TestLoggerFactory.cs).The remaining ~82 runner-agnostic files (~6,500 LOC — all
Commandclasses,TestAsset/TestAssetsManager, assertions, project construction,SdkTest) reference the test-output sink only through the unqualified nameITestOutputHelper, supplied today via a global<Using Include=""Xunit"" />.What this PR does
Adds a new
test/Microsoft.NET.TestFramework.MSTestproject that link-shares the ~82 agnostic source files from the legacy framework (zero duplication) and supplies the MSTest-specific pieces locally:ITestOutputHelper.csXunit.ITestOutputHelperTestContextOutputHelper.csTestContext-backed implementationSdkTest.csTestContextproperty instead of constructor injection)TestLoggerFactory.csXunitLoggerProvider)Supporting changes:
InternalsVisibleTogrants for the new assembly fromMicrosoft.DotNet.Cli.UtilsandMicrosoft.DotNet.InternalAbstractions(the link-sharedMock/*helpers use their internals).sdk.slnx.The namespace is kept as
Microsoft.NET.TestFrameworkso that, once every consumer has migrated, the legacy project can be deleted and this one renamed with no source churn.Validation
Builds clean on net11.0 and net472 (0 warnings / 0 errors). No existing project is touched, so the 53 current xUnit consumers are unaffected.
Onboarding roadmap (follow-ups)
[OSCondition](MSTest 4.3) covers OS gating; the MSBuild variants (CoreMSBuildOnly/FullMSBuildOnly/RequiresMSBuildVersion) needConditionBaseAttributesubclasses.AspNetSdkTestbase.Microsoft.NET.TestFrameworkand rename this project.Co-authored-by: Copilot [email protected]