Skip to content

Migrate TemplateEngine test projects to MSTest.Sdk on MTP#54883

Open
Evangelink wants to merge 13 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-templateengine
Open

Migrate TemplateEngine test projects to MSTest.Sdk on MTP#54883
Evangelink wants to merge 13 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-templateengine

Conversation

@Evangelink

@Evangelink Evangelink commented Jun 19, 2026

Copy link
Copy Markdown
Member

Migrates the TemplateEngine test projects from xUnit to MSTest.Sdk on Microsoft.Testing.Platform (MTP), following the established repo pattern.

Projects:

  • Microsoft.TemplateEngine.Core.UnitTests
  • Microsoft.TemplateEngine.Edge.UnitTests
  • Microsoft.TemplateEngine.Authoring.CLI.UnitTests
  • Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests
  • Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests
  • Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests
  • Microsoft.TemplateEngine.IDE.IntegrationTests
  • Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests

With the last two added, every xUnit test project under test/TemplateEngine is now on MSTest.Sdk.

Infra:

  • Adds Verify.MSTest to eng/dependabot/Packages.props, eng/Packages.props and eng/Signing.props.
  • test/TemplateEngine/Directory.Build.props now references Microsoft.NET.TestFramework.MSTest for UsingMSTestSdk projects (and keeps the xUnit framework for the rest).

Note: Microsoft.TemplateEngine.Cli.UnitTests is migrated separately in #54761. The migrated tests still bridge to the shared Microsoft.TemplateEngine.TestHelper (EnvironmentSettingsHelper(IMessageSink)), which remains xUnit-coupled and is out of scope here; handled via a local NullMessageSink.

IClassFixture fixtures became per-class ClassInitialize/ClassCleanup; [Theory]/[InlineData] -> [TestMethod]/[DataRow]; Assert.Throws<T> -> Assert.ThrowsExactly<T>; Verify snapshot setup moved into [ClassInitialize]; and [DoNotParallelize] was applied to shared-state/snapshot/culture-mutating classes (MSTest runs method-level parallel by default).

Part of the xUnit -> MSTest migration effort. Each project builds cleanly; tests were not run as part of this change.

Migrates the following to MSTest.Sdk (Microsoft.Testing.Platform):
- Microsoft.TemplateEngine.Core.UnitTests
- Microsoft.TemplateEngine.Edge.UnitTests
- Microsoft.TemplateEngine.Authoring.CLI.UnitTests
- Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests
- Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests
- Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests

Adds Verify.MSTest (eng/dependabot/Packages.props, eng/Packages.props,
eng/Signing.props) and makes test/TemplateEngine/Directory.Build.props
reference Microsoft.NET.TestFramework.MSTest for UsingMSTestSdk projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 08:03

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 several TemplateEngine-related test projects from xUnit to MSTest.Sdk (with Microsoft.Testing.Platform usage implied by the repo’s MSTest setup), aligning these projects with the repo’s established MSTest migration pattern and enabling Verify-based snapshot testing in MSTest via Verify.MSTest.

Changes:

  • Switched multiple TemplateEngine test projects to Sdk="MSTest.Sdk" and converted xUnit attributes/assertions to MSTest equivalents.
  • Added MSTest-specific plumbing (GlobalUsings aliases, TestContextLogger, NullMessageSink) to keep shared helpers compiling and preserve per-test logging.
  • Updated repo infra props to include Verify.MSTest and sign its assembly; adjusted TemplateEngine test Directory.Build.props to reference Microsoft.NET.TestFramework.MSTest for MSTest projects.
Show a summary per file
File Description
eng/Packages.props Adds Verify.MSTest package version wiring.
eng/Signing.props Adds signing entry for Verify.MSTest.dll.
test/TemplateEngine/Directory.Build.props Switches test framework project reference based on UsingMSTestSdk.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/ExportCommandFailureTests.cs Migrates tests to MSTest and routes command logging via ILogger backed by TestContext.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/ExportCommandTests.cs Migrates tests to MSTest and adapts assertions/async APIs.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/GlobalUsings.cs Adds aliases to disambiguate MSTest Assert/TestContext and keep shared ITestOutputHelper references compiling.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests.csproj Switches project to MSTest.Sdk and adds MSTest experimental warning suppression.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/TestContextLogger.cs New logger that forwards ILogger output to MSTest TestContext.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/ValidateCommandTests.cs Converts Verify-based integration test to MSTest and initializes Verify settings via [ClassInitialize].
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/VerifyCommandTests.cs Migrates ignored Verify CLI tests to MSTest and swaps output plumbing to ILogger.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/VerifySettingsFixture.cs Adjusts Verify initialization for MSTest usage.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/VerifyTestCollection.cs Removes xUnit collection fixture usage and documents new MSTest init approach.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/GlobalUsings.cs Adds aliases to disambiguate MSTest Assert/TestContext and keep shared ITestOutputHelper references compiling.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/Microsoft.TemplateEngine.Authoring.CLI.UnitTests.csproj Switches project to MSTest.Sdk and adds MSTest experimental warning suppression.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/ValidateCommandTests.cs Converts xUnit tests to MSTest and updates assertions/token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/VerifyCommandArgsTests.cs Converts xUnit theory data to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/VerifyCommandTests.cs Converts xUnit theory to MSTest DynamicData.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/AuthoringTemplatesTests.cs Migrates tests to MSTest and adapts logging to TestContext.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/GlobalUsings.cs Adds aliases to disambiguate MSTest Assert/TestContext and keep shared ITestOutputHelper references compiling.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests.csproj Switches project to MSTest.Sdk and adds MSTest experimental warning suppression.
test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/TestContextLogger.cs New logger that forwards ILogger output to MSTest TestContext.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/BalancedNestingTests.cs Migrates xUnit tests to MSTest and replaces assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ChunkStreamReadTests.cs Migrates xUnit tests to MSTest and updates environment helper lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/CombinedStreamTests.cs Converts xUnit theory to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/CommonOperationsTests.cs Migrates xUnit tests to MSTest and updates logger fixture handling.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.cs Switches to MSTest and reworks fixture-style initialization via [ClassInitialize].
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.HashCommentWithCStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.HamlLineCommenting.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.InlineMarkup.cs Converts xUnit tests to MSTest and updates logger factory fixture handling.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.JsxBlockComments.cs Converts xUnit theories to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.LineCommentingWithNestedCommentsWithCStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.NestedConditionsWithCStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.NestedConditionsWithVbStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.RazorBlockComments.cs Converts xUnit theories to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.RemCommentWithCStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.UncommentingBehavior.cs Converts xUnit facts/theories to MSTest.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.VBStyleEvaluator.cs Converts xUnit facts to MSTest methods.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.XmlBlockComments.cs Converts xUnit facts to MSTest and replaces skip semantics with [Ignore].
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/Cpp2EvaluatorTests.cs Migrates xUnit tests to MSTest and updates logger factory fixture handling.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/LookaroundTests.cs Migrates xUnit tests to MSTest and updates environment helper lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/Microsoft.TemplateEngine.Core.UnitTests.csproj Switches project to MSTest.Sdk.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/NullMessageSink.cs New xUnit IMessageSink stub to satisfy xUnit-coupled helper code.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/OperationTrieTests.cs Migrates xUnit tests to MSTest and updates assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/OrchestratorTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/PhasedOperationTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/RegionTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ReplacementTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/SetFlagTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/StreamProxyTests.cs Migrates xUnit tests to MSTest.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs Replaces xUnit assertions with MSTest equivalents in shared test helpers.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/TokenTrieTests.cs Converts xUnit theory/data to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/TrieTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/VariablesTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/AllComponents.cs Migrates xUnit tests to MSTest and updates sequence assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/FolderInstallerTests.cs Migrates xUnit tests to MSTest and adapts helper lifecycle/cancellation token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/GeneratorTests.cs Migrates xUnit tests to MSTest and updates cancellation token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/GlobalSettingsTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/HostConstraintTests.cs Migrates xUnit tests to MSTest and updates assertions/token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/LocalizationTests.cs Migrates xUnit tests to MSTest and updates assertions/token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/Microsoft.TemplateEngine.Edge.UnitTests.csproj Switches project to MSTest.Sdk.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NullMessageSink.cs New xUnit IMessageSink stub to satisfy xUnit-coupled helper code.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NuGetVersionHelperTests.cs Converts xUnit theories to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/OSConstraintTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/PathInfoTests.cs Converts xUnit tests/theories to MSTest DataRow.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/SdkVersionConstraintTests.cs Converts xUnit theories to MSTest DataRow and updates cancellation token usage.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs Migrates xUnit fixture usage to MSTest class lifecycle and updates assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs Migrates xUnit fixture usage to MSTest class lifecycle.
test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/WorkloadConstraintTests.cs Converts xUnit theories to MSTest DataRow and updates cancellation token usage.
test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/GlobalUsings.cs Adds aliases to disambiguate MSTest Assert/TestContext and keep shared ITestOutputHelper references compiling.
test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests.csproj Switches project to MSTest.Sdk and adds MSTest experimental warning suppression.
test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs Migrates xUnit test to MSTest and updates assertions/token usage.
test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/TestContextLogger.cs New logger that forwards ILogger output to MSTest TestContext.

Copilot's findings

  • Files reviewed: 79/79 changed files
  • Comments generated: 3

Evangelink and others added 2 commits June 19, 2026 16:29
…lderInstallerTests

- Assert on uninstallResult (not the install result) in CanUninstall_Success
- Mark FolderInstallerTests [DoNotParallelize] since it shares a static
  EnvironmentSettingsHelper with non-thread-safe mutable state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MTP (MSTest.Sdk) test apps were always invoked via 'dotnet exec <target>'.
For .NET Framework targets TargetPath is the native '.exe', which has no
runtimeconfig.json, so 'dotnet exec' treats it as a self-contained .NET Core
app and fails with 'hostpolicy.dll ... not found' (exit -2147450749). Launch
the .exe directly for .NETFramework while keeping 'dotnet exec <dll>' for
.NET (Core).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink and others added 2 commits June 20, 2026 09:46
…sts to MSTest.Sdk on MTP

Completes the TemplateEngine xUnit -> MSTest.Sdk migration by porting the two remaining test projects, following the established pattern (Verify.MSTest, IClassFixture -> ClassInitialize/ClassCleanup with NullMessageSink, [Theory]/[InlineData] -> [TestMethod]/[DataRow], Assert.Throws -> Assert.ThrowsExactly, [DoNotParallelize] on shared-state/snapshot classes).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink enabled auto-merge June 20, 2026 12:55
Copilot AI and others added 3 commits June 20, 2026 16:47
Route the shared TemplateVerifier engine's directory verification through a
pluggable seam so MSTest-migrated tests use the MSTest Verify adapter (the
engine stays compiled against the xUnit adapter for its remaining xUnit
consumers). Wire the ambient MSTest TestContext into Verify for every
verifying test class, add Verify.MSTest where missing, and mark the
shared-static Edge test classes [DoNotParallelize].

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verify.MSTest (31.19.0) pulls in Verify's solution auto-discovery, which searches only the project directory and its two parents for a .sln/.slnx. Test projects nested under test/TemplateEngine are three levels below the repo-root sdk.slnx, so single-project (Helix) builds fail discovery and emit a warning promoted to an error by warnaserror. Set SolutionDir/SolutionName explicitly so discovery is skipped.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink and others added 4 commits June 22, 2026 19:23
…ithExternalEvaluation

The xUnit version compared e.Message.Should().BeEquivalentTo(e.Message) (a tautology that never validated the message). The MTP migration changed it to assert against expectedErrorMessage, exposing that the DataRow's expected string was wrong. Update it to the actual engine message (EvaluatedInputDataSet_Error_MismatchedConditions with the offending parameter rendered as 'parB (parameter): <null>').

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants