Migrate TemplateEngine test projects to MSTest.Sdk on MTP#54883
Open
Evangelink wants to merge 13 commits into
Open
Migrate TemplateEngine test projects to MSTest.Sdk on MTP#54883Evangelink wants to merge 13 commits into
Evangelink wants to merge 13 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
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.MSTestand sign its assembly; adjusted TemplateEngine test Directory.Build.props to referenceMicrosoft.NET.TestFramework.MSTestfor 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
…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
commented
Jun 19, 2026
…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>
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>
…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>
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 test projects from xUnit to
MSTest.Sdkon Microsoft.Testing.Platform (MTP), following the established repo pattern.Projects:
Microsoft.TemplateEngine.Core.UnitTestsMicrosoft.TemplateEngine.Edge.UnitTestsMicrosoft.TemplateEngine.Authoring.CLI.UnitTestsMicrosoft.TemplateEngine.Authoring.CLI.IntegrationTestsMicrosoft.TemplateEngine.Authoring.Templates.IntegrationTestsMicrosoft.TemplateSearch.TemplateDiscovery.IntegrationTestsMicrosoft.TemplateEngine.IDE.IntegrationTestsMicrosoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTestsWith the last two added, every xUnit test project under
test/TemplateEngineis now onMSTest.Sdk.Infra:
Verify.MSTesttoeng/dependabot/Packages.props,eng/Packages.propsandeng/Signing.props.test/TemplateEngine/Directory.Build.propsnow referencesMicrosoft.NET.TestFramework.MSTestforUsingMSTestSdkprojects (and keeps the xUnit framework for the rest).Note:
Microsoft.TemplateEngine.Cli.UnitTestsis migrated separately in #54761. The migrated tests still bridge to the sharedMicrosoft.TemplateEngine.TestHelper(EnvironmentSettingsHelper(IMessageSink)), which remains xUnit-coupled and is out of scope here; handled via a localNullMessageSink.IClassFixturefixtures became per-classClassInitialize/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.