Migrate Microsoft.TemplateEngine.Cli.UnitTests to MSTest.Sdk on MTP#54761
Open
Evangelink wants to merge 3 commits into
Open
Migrate Microsoft.TemplateEngine.Cli.UnitTests to MSTest.Sdk on MTP#54761Evangelink wants to merge 3 commits into
Evangelink wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates Microsoft.TemplateEngine.Cli.UnitTests from xUnit v3 to MSTest.Sdk on Microsoft.Testing.Platform (MTP), aligning the project with the newer MSTest + MTP execution model and switching snapshot tests to Verify’s MSTest integration.
Changes:
- Switch the test project to
MSTest.Sdk, replace xUnit attributes/asserts with MSTest equivalents, and convert theories to[DataRow]/[DynamicData]. - Move snapshot/approval tests to
Verify.MSTestand introduce supporting infrastructure (VerifyBaseinheritance, global usings, null xUnit message sink shim). - Update repo-wide package/signing metadata to include
Verify.MSTest.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.TemplateEngine.Cli.UnitTests/Microsoft.TemplateEngine.Cli.UnitTests.csproj | Switch to MSTest.Sdk, mark as test project, move snapshots to Verify.MSTest. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/GlobalUsings.cs | Add global usings/aliases needed for MSTest + Verify + shared xUnit types; enable DiscoverInternals. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/BaseTest.cs | Base class now derives from VerifyBase to support Verify snapshot testing. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/NullMessageSink.cs | Provide no-op IMessageSink for shared helper construction without an xUnit runner. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplateSearchCoordinatorTests.cs | Convert to MSTest attributes/asserts; update search assertions and async patterns. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplatePackageDisplayTest.cs | Convert tests/asserts to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplatePackageCoordinatorTests.cs | Convert tests/asserts to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TelemetryHelperTests.cs | Convert tests/asserts to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TabularOutputTests.cs | Convert tests/asserts to MSTest equivalents; use sequence assertions. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/JExtensionsTests.cs | Convert to MSTest [TestClass]/[TestMethod]. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/HostDataLoaderTests.cs | Replace xUnit fixture with MSTest init/cleanup pattern; convert asserts. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/PostActionDispatcherTests.cs | Replace xUnit fixture with MSTest init/cleanup pattern; convert asserts. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/PostActionTests/AddJsonPropertyPostActionTests.cs | Replace xUnit fixture with MSTest init/cleanup; convert theories to DynamicData. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplateResolutionTests/ListTemplateResolverTests.cs | Convert to MSTest attributes/asserts; update async call sites. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplateResolutionTests/TemplateResolutionResultTests.cs | Convert assertions to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/TemplateResolutionTests/TemplateMatchInfoTests.cs | Convert assertions to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/AllComponents.cs | Convert to MSTest and use sequence assertions. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/AliasAssignmentTests.cs | Convert to MSTest, update asserts and data-driven tests. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/HelpTests.cs | Convert to MSTest and make the test class use Verify.MSTest base. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/HelpTests.Resolution.cs | Convert resolution tests to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/TabCompletionTests.cs | Convert to MSTest equivalents; update completion assertions and skips. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/TabCompletionTests.Approval.cs | Convert approval/snapshot tests to MSTest [TestMethod]. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/TemplateCommandTests.cs | Convert constraint tests to MSTest equivalents. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/InstallTests.cs | Convert parsing tests to MSTest equivalents and data-driven form. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/UninstallTests.cs | Convert parsing tests to MSTest equivalents and data-driven form. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/UpdateTests.cs | Convert parsing tests to MSTest equivalents and data-driven form. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/SearchTests.cs | Convert parsing tests to MSTest equivalents and data-driven form. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/ListTests.cs | Convert parsing tests to MSTest equivalents and data-driven form. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/MiscTests.cs | Convert tests/asserts to MSTest equivalents; use sequence assertions. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/InstantiateTests.cs | Convert to MSTest, adapt data-driven tests and assertions. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/InstantiateTests.Subcommand.cs | Convert to MSTest; adapt dynamic data usage and assertions. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/InstantiateTests.NoMatchHandling.cs | Convert to MSTest; adapt dynamic data usage and assertions. |
| eng/Signing.props | Add signing entry for Verify.MSTest.dll. |
| eng/Packages.props | Add Verify.MSTest package version override hook for source-build. |
| eng/dependabot/Packages.props | Add Verify.MSTest version to dependabot-managed package list. |
Copilot's findings
- Files reviewed: 35/35 changed files
- Comments generated: 4
| SearchCommandArgs args = new((SearchCommand)parseResult.CommandResult.Command, parseResult); | ||
|
|
||
| IReadOnlyList<IManagedTemplatePackage> templatePackages = await templatePackageManager.GetManagedTemplatePackagesAsync(false, TestContext.Current.CancellationToken); | ||
| IReadOnlyList<IManagedTemplatePackage> templatePackages = await templatePackageManager.GetManagedTemplatePackagesAsync(false, CancellationToken.None); |
Comment on lines
+97
to
+100
| IReadOnlyList<SearchResult> searchResults = await searchCoordinator.SearchAsync( | ||
| factory.GetPackFilter(args), | ||
| CliSearchFiltersFactory.GetMatchingTemplatesFilter(args), | ||
| TestContext.Current.CancellationToken); | ||
| CancellationToken.None); |
Comment on lines
+29
to
+32
| TemplateResolutionResult matchResult = await resolver.ResolveTemplatesAsync( | ||
| GetListCommandArgsFor("new list console2"), | ||
| defaultLanguage: null, | ||
| TestContext.Current.CancellationToken); | ||
| CancellationToken.None); |
Comment on lines
+448
to
+455
| [TestMethod] | ||
| public void CanIgnoreTemplateGroupsWithConstraints() | ||
| { | ||
| if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) | ||
| { | ||
| Assert.Inconclusive("Skipped on Linux: https://github.com/dotnet/sdk/issues/46212"); | ||
| } | ||
|
|
…Token.None Replaces CancellationToken.None (introduced during xUnit->MSTest migration as a stand-in for xUnit's TestContext.Current.CancellationToken) with TestContext.CancellationTokenSource.Token on the four test classes that previously used it. Adds the required TestContext property (with 'new' modifier for VerifyBase-derived classes that inherit one). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The class calls Verify(e.Message) which requires VerifyBase from Verify.MSTest (it works for HelpTests and TabCompletionTests which already inherit from VerifyBase / BaseTest). Without it, Verify.MSTest's runtime path tries to resolve TestContext through the legacy Microsoft.VisualStudio.TestPlatform. TestFramework.Extensions assembly (v14) which is not part of MSTest 4.x and is not deployed, producing FileNotFoundException for every test in the class. Use 'new TestContext' to override VerifyBase's TestContext property and bind to the modern MSTest.TestFramework type so TestContext.CancellationTokenSource.Token continues to compile and resolve correctly at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Migrates the TemplateEngine.Cli.UnitTests project from xUnit v3 to MSTest.Sdk on Microsoft.Testing.Platform. Follows the same pattern as #54758 and #54759.
cc @Evangelink