Migrate dotnet-new.IntegrationTests to MSTest.Sdk on MTP#54904
Open
Evangelink wants to merge 7 commits into
Open
Migrate dotnet-new.IntegrationTests to MSTest.Sdk on MTP#54904Evangelink wants to merge 7 commits into
Evangelink wants to merge 7 commits into
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-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
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>
# 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>
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, 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.