Skip to content

Migrate dotnet-new.IntegrationTests to MSTest.Sdk on MTP#54904

Open
Evangelink wants to merge 7 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-dotnetnew-tests
Open

Migrate dotnet-new.IntegrationTests to MSTest.Sdk on MTP#54904
Evangelink wants to merge 7 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-dotnetnew-tests

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Part of the ongoing xUnit -> MSTest.Sdk (MTP) test migration of the .NET SDK test suite, following the same pattern as the other open migration PRs (builds on the foundation merged in #54845).

~13 IClassFixture usages become static [ClassInitialize]/Lazy fixtures; a [Collection] becomes [DoNotParallelize]; Verify.XunitV3 -> Verify.MSTest and Xunit.Combinatorial -> Combinatorial.MSTest. The Verify approval snapshots are intentionally left containing xUnit content (they are generated dotnet new template output).

Standard transformations: Microsoft.NET.Sdk -> MSTest.Sdk, the TestFramework project reference -> Microsoft.NET.TestFramework.MSTest, [Fact]/[Theory] -> [TestMethod], [InlineData] -> [DataRow], xUnit asserts -> MSTest (including the repo Recommended-mode idiomatic asserts), and ITestOutputHelper constructor injection removed in favour of the base SdkTest Log / TestContext.

Builds clean for the SDK target framework.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 18:26
@Evangelink Evangelink requested a review from a team as a code owner June 19, 2026 18:26

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-new.IntegrationTests from xUnit to MSTest.Sdk (MTP), aligning this test suite with the ongoing SDK-wide migration and the Microsoft.NET.TestFramework.MSTest base infrastructure.

Changes:

  • Converted tests to MSTest attributes ([TestClass], [TestMethod], [DataRow], [DynamicData], [Ignore]) and updated assertions/logging to MSTest/TestFramework patterns.
  • Replaced xUnit fixtures/collections with MSTest [ClassInitialize]/[ClassCleanup] static fixtures and applied targeted parallelization controls.
  • Updated the test project file to use MSTest.Sdk, Verify.MSTest, and added package/reference adjustments to avoid transitive xUnit compile-time type conflicts.
Show a summary per file
File Description
test/dotnet-new.IntegrationTests/BaseIntegrationTest.cs Switches base test class to MSTest-friendly parameterless construction.
test/dotnet-new.IntegrationTests/CommonTemplatesTests.cs Migrates template verification tests to MSTest data-driven patterns and cancellation token usage.
test/dotnet-new.IntegrationTests/Diagnostic/DiagnosticFixture.cs Retains (now-empty) fixture type for compatibility after xUnit sink removal.
test/dotnet-new.IntegrationTests/Diagnostic/XunitNuGetLogger.cs Ports diagnostic logger output from xUnit message sink to ITestOutputHelper.
test/dotnet-new.IntegrationTests/dotnet-new.IntegrationTests.csproj Moves project to MSTest.Sdk, replaces Verify package, and suppresses transitive xUnit compile-type conflicts.
test/dotnet-new.IntegrationTests/DotnetClassTemplateTests.cs Converts data-driven template verifier tests to MSTest + TestContext.CancellationToken.
test/dotnet-new.IntegrationTests/DotnetNewArgumentsTests.cs Reworks to MSTest with explicit TestContext and output helper wiring.
test/dotnet-new.IntegrationTests/DotnetNewCompleteTests.cs Converts completion tests to [TestMethod]/[Ignore].
test/dotnet-new.IntegrationTests/DotnetNewDebugOptionsTests.cs Converts tests and assertion APIs to MSTest idioms.
test/dotnet-new.IntegrationTests/DotnetNewDetailsTest.cs Removes xUnit diagnostic fixture dependency; migrates to MSTest attributes.
test/dotnet-new.IntegrationTests/DotnetNewDetailsTest.Approval.cs Converts approval/Verify tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewHelpTests.cs Replaces xUnit fixture usage with static MSTest class fixture.
test/dotnet-new.IntegrationTests/DotnetNewHelpTests.Approval.cs Adds [TestClass] + converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs Migrates install tests to MSTest and replaces message sink logging with ITestOutputHelper.
test/dotnet-new.IntegrationTests/DotnetNewInstallTests.Approval.cs Converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewInstantiateTests.cs Migrates instantiate tests to MSTest and updates assertions.
test/dotnet-new.IntegrationTests/DotnetNewInstantiateTests.Approval.cs Converts approval/Verify tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewListTests.cs Uses MSTest class fixture and converts list tests to [TestMethod]/[DataRow].
test/dotnet-new.IntegrationTests/DotnetNewListTests.Approval.cs Converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewLocaleTests.cs Converts locale tests to MSTest attributes and output helper usage.
test/dotnet-new.IntegrationTests/DotnetNewSearchTests.cs Migrates search tests from xUnit to MSTest data-driven patterns and assertions.
test/dotnet-new.IntegrationTests/DotnetNewSearchTests.Approval.cs Converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewTests.cs Replaces xUnit fixture with static MSTest class fixture; converts tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs Converts xUnit MemberData to MSTest DynamicData and test methods to [TestMethod].
test/dotnet-new.IntegrationTests/DotnetNewUninstallTests.cs Converts uninstall tests to MSTest data-driven tests and assertions.
test/dotnet-new.IntegrationTests/DotnetNewUninstallTests.Approval.cs Converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/DotnetNewUpdateTests.cs Converts update tests to MSTest data-driven tests and assertions.
test/dotnet-new.IntegrationTests/DotnetNewUpdateTests.Approval.cs Converts approval tests to MSTest.
test/dotnet-new.IntegrationTests/FileRenameTests.cs Migrates to MSTest and updates regex assertion usage.
test/dotnet-new.IntegrationTests/FirstRunTest.cs Migrates to MSTest attributes and output helper usage.
test/dotnet-new.IntegrationTests/McpServerTemplateTests.cs Migrates fixture + data-driven restore/build tests to MSTest.
test/dotnet-new.IntegrationTests/MSBuildEvaluationTests.cs Converts MSBuild evaluation tests to MSTest with updated assertions.
test/dotnet-new.IntegrationTests/PostActionTests.cs Migrates a large suite of post-action integration tests to MSTest data-driven equivalents.
test/dotnet-new.IntegrationTests/PostActionTests.Approval.cs Converts approval/Verify post-action tests to MSTest.
test/dotnet-new.IntegrationTests/SharedHomeDirectory.cs Updates shared home directory helper to use ITestOutputHelper rather than xUnit sink.
test/dotnet-new.IntegrationTests/SourcesTests.cs Migrates sources tests to MSTest and updates sequence assertions.
test/dotnet-new.IntegrationTests/TemplateDiscoveryTool.cs Removes xUnit sink dependency; uses ITestOutputHelper for tool output.
test/dotnet-new.IntegrationTests/TemplateDiscoveryTests.cs Converts to MSTest class fixture + condition attributes + updated assertions.
test/dotnet-new.IntegrationTests/TemplateEngineSamplesTest.cs Migrates sample verifier tests to MSTest and marks class non-parallel.
test/dotnet-new.IntegrationTests/WebProjectsTests.cs Migrates restore/build web template tests to MSTest class fixture + data rows.

Copilot's findings

  • Files reviewed: 40/40 changed files
  • Comments generated: 5

Comment thread test/dotnet-new.IntegrationTests/WebProjectsTests.cs
Comment thread test/dotnet-new.IntegrationTests/McpServerTemplateTests.cs
Comment thread test/dotnet-new.IntegrationTests/CommonTemplatesTests.cs
Comment thread test/dotnet-new.IntegrationTests/TemplateEngineSamplesTest.cs Outdated
Comment thread test/dotnet-new.IntegrationTests/DotnetNewLocaleTests.cs
Evangelink and others added 2 commits June 19, 2026 22:24
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The migrated Verify approval tests call the static VerifyMSTest.Verifier.Verify(...)
which reads the test context from Verifier.CurrentTestContext. Nothing was wiring
that AsyncLocal because no [UsesVerify] marker was present, so the Verify.MSTest
source generator never emitted the TestContext property setter that captures it,
causing 'TestContext is null' at runtime.

Mark BaseIntegrationTest with [UsesVerify] (and make it partial) so the generator
emits a sealed override TestContext on it (inherited by every Verify-using test
class), and make SdkTest.TestContext virtual so that override is legal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink enabled auto-merge June 20, 2026 08:34
Evangelink and others added 3 commits June 22, 2026 11:56
# Conflicts:
#	test/Microsoft.NET.TestFramework.MSTest/SdkTest.cs
MSTest (via the recent testfx bump) now ships its own ArchitectureConditionAttribute, which collides with Microsoft.NET.TestFramework.ArchitectureConditionAttribute and caused CS0104 in TemplateDiscoveryTests. Fully-qualify the attribute to the TestFramework one to preserve existing process-architecture gating behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The testfx bump (dotnet#54765) elevated MSTEST0071 to an error under MSTestAnalysisMode=Recommended, breaking main: the dotnet.Tests New post-action tests set [TestMethod(DisplayName = nameof(Method))], which MSTEST0071 flags as redundant. Drop the DisplayName so the display name defaults to the method name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants