Skip to content

Migrate Microsoft.TemplateEngine.Cli.UnitTests to MSTest.Sdk on MTP#54761

Open
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-templateengine-cli
Open

Migrate Microsoft.TemplateEngine.Cli.UnitTests to MSTest.Sdk on MTP#54761
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-templateengine-cli

Conversation

@Evangelink

Copy link
Copy Markdown
Member

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

Copilot AI review requested due to automatic review settings June 13, 2026 16:16
@Evangelink Evangelink requested a review from a team as a code owner June 13, 2026 16:16

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 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.MSTest and introduce supporting infrastructure (VerifyBase inheritance, 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");
}

Evangelink and others added 2 commits June 13, 2026 18:27
…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>
@Evangelink

Copy link
Copy Markdown
Member Author

/azp run dotnet-sdk-public-ci

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@Evangelink

Copy link
Copy Markdown
Member Author

/azp run dotnet-sdk-public-ci

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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