Repository navigation
Remove xUnit from TemplateEngine test helpers - #55067
Merged
Merged
Conversation
Replace the xUnit IMessageSink-based diagnostic plumbing in the TestHelper library with a non-xUnit Action<string> write callback: - XunitLoggerProvider -> TestLoggerProvider (logs via Action<string>) - Delete SharedTestOutputHelper (xUnit ITestOutputHelper wrapper) - EnvironmentSettingsHelper / TestLoggerFactory ctors take Action<string>? - Drop the xunit.v3.extensibility.core PackageReference and update PublicAPI Remove the IXunitSerializable implementations from the Mocks library (MockCreationEffects, MockFileChange, MockTemplateInfo); MSTest data sources do not require xUnit serialization. Drop the xunit.v3.extensibility.core PackageReference. Co-authored-by: Copilot <[email protected]>
- Delete the 7 per-project NullMessageSink.cs no-op xUnit IMessageSink implementations and update the ~53 EnvironmentSettingsHelper call sites to use the new parameterless (Action<string>?) constructor. - Remove the IMessageSink/IMessageSinkMessage xUnit global-using aliases from Cli.UnitTests, TemplateSearch.Common.UnitTests and Utils.UnitTests. - Remove the now-dead 'ITestOutputHelper = Xunit.ITestOutputHelper' global-using aliases from projects that do not compile the shared CommandUtils sources (Orchestrator.RunnableProjects, IDE, Authoring.CLI unit/integration, TemplateSearch.TemplateDiscovery, Authoring.Templates). - Authoring.Tasks.IntegrationTests does compile the shared CommandUtils sources (src/TemplateEngine/Tools/Shared) which reference ITestOutputHelper by short name; repoint its alias to the runner-agnostic Microsoft.NET.TestFramework.ITestOutputHelper and reference Microsoft.NET.TestFramework.MSTest so it compiles without any xUnit dependency. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the remaining functional xUnit dependencies from the TemplateEngine test helper libraries and in-scope TemplateEngine/Cli test projects by replacing xUnit-based logging/serialization helpers with runner-agnostic equivalents and updating call sites accordingly.
Changes:
- Replace xUnit
ITestOutputHelper/IMessageSink-based logging helpers with anAction<string>callback-based logger provider/factory. - Remove
IXunitSerializablefrom TemplateEngine mock data classes and delete per-projectNullMessageSinkshims. - Update TemplateEngine/Cli tests and global usings to compile without xUnit (including a runner-agnostic
ITestOutputHelperalias for the one project that links shared CommandUtils sources).
Show a summary per file
| File | Description |
|---|---|
| test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/TemplateSearchCoordinatorTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/TemplateSearchCacheReaderTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/NuGetMetadataSearchProviderTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateSearch.Common.UnitTests/GlobalUsings.cs | Removes xUnit IMessageSink aliases from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Utils.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateEngine.Utils.UnitTests/InstallRequestPathResolutionTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Utils.UnitTests/GlobalUsings.cs | Removes xUnit IMessageSink aliases from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Utils.UnitTests/DefaultTemplatePackageProviderTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/TestLoggerProvider.cs | Introduces callback-based logger provider (replacing xUnit output helper usage). |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/TestLoggerFactory.cs | Updates logger factory ctor to accept Action<string> (but currently has a compile issue). |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/SharedTestOutputHelper.cs | Deletes xUnit IMessageSink-based output helper implementation. |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PublicAPI.Unshipped.txt | Updates public API surface for new ctor and provider type names. |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/Microsoft.TemplateEngine.TestHelper.csproj | Removes xunit.v3.extensibility.core PackageReference. |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/EnvironmentSettingsHelper.cs | Replaces IMessageSink logging dependency with Action<string> callback. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/TemplateJsonDefinedFormsTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValidationTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/TemplateRootTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/SplitConfigurationTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/SourceConfigTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/PostActionTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/LocalizationTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/FileRenameTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ScanTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/RunnableProjectGeneratorTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/RunnableProjectConfigTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/SwtichMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RegexMatchMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RegexMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RandomMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/NowMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/JoinMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GuidMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GeneratePortMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/FakeMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/EvaluateMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/ConstantMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/CoalesceMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/CaseChangeMacroTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroProcessorTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/BindSymbolTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs | Removes IXunitSerializable implementation from mock template info. |
| test/TemplateEngine/Microsoft.TemplateEngine.Mocks/MockFileChange.cs | Removes IXunitSerializable implementation from mock file change. |
| test/TemplateEngine/Microsoft.TemplateEngine.Mocks/MockCreationEffects.cs | Removes IXunitSerializable implementation from mock creation effects. |
| test/TemplateEngine/Microsoft.TemplateEngine.Mocks/Microsoft.TemplateEngine.Mocks.csproj | Removes xunit.v3.extensibility.core PackageReference. |
| test/TemplateEngine/Microsoft.TemplateEngine.IDE.IntegrationTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateEngine.IDE.IntegrationTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplatePackageManagerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/OSConstraintTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NuGetInstallerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NuGetApiPackageManagerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/LocalizationTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/GlobalSettingsTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/FolderInstallerTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/VariablesTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/SetFlagTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ReplacementTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/RegionTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/OrchestratorTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/LookaroundTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ChunkStreamReadTests.cs | Switches EnvironmentSettingsHelper construction to parameterless (also normalizes header). |
| test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests/Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests.csproj | Adds MSTest test framework reference to supply runner-agnostic ITestOutputHelper. |
| test/TemplateEngine/Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests/GlobalUsings.cs | Rebinds ITestOutputHelper alias to Microsoft.NET.TestFramework.ITestOutputHelper. |
| test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.UnitTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/GlobalUsings.cs | Removes xUnit ITestOutputHelper alias from global usings. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/PostActionTests/AddJsonPropertyPostActionTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/PostActionDispatcherTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/NullMessageSink.cs | Deletes xUnit IMessageSink no-op shim. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/HostDataLoaderTests.cs | Switches EnvironmentSettingsHelper construction to parameterless. |
| test/Microsoft.TemplateEngine.Cli.UnitTests/GlobalUsings.cs | Removes xUnit IMessageSink aliases from global usings. |
Copilot's findings
- Files reviewed: 81/81 changed files
- Comments generated: 1
Co-authored-by: Copilot <[email protected]>
Evangelink
enabled auto-merge
June 30, 2026 10:03
YuliiaKovalova
approved these changes
Jun 30, 2026
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.
Summary
Migrates the SDK-owned TemplateEngine test code off xUnit. The remaining xUnit usage in this area was concentrated in the shared test-helper libraries (an
Xunit.Sdk.IMessageSink-based diagnostic-logging mechanism) and theIXunitSerializablemock data classes. This removes all of it so the in-scope projects contain zero functional xUnit.Scope:
test/TemplateEngine/**andtest/Microsoft.TemplateEngine.Cli.UnitTests/**only.What changed
Helper libraries (
Microsoft.NET.Sdk, not MSTest.Sdk)Microsoft.TemplateEngine.TestHelperXunitLoggerProvider→TestLoggerProvider: logs through aSystem.Action<string>write callback instead of xUnit'sITestOutputHelper.SharedTestOutputHelper.cs(anXunit.ITestOutputHelperwrapper aroundIMessageSinkthat emittedDiagnosticMessage).EnvironmentSettingsHelperandTestLoggerFactoryconstructors now take an optionalAction<string>?instead ofXunit.Sdk.IMessageSink?.xunit.v3.extensibility.corePackageReference; updatedPublicAPI.Unshipped.txt.Microsoft.TemplateEngine.MocksIXunitSerializable(and theSerialize/Deserializemembers) fromMockCreationEffects,MockFileChange,MockTemplateInfo. MSTest data sources don't need xUnit serialization.xunit.v3.extensibility.corePackageReference.Test projects
NullMessageSink.csno-opIMessageSinkimplementations and updated the ~53new EnvironmentSettingsHelper(NullMessageSink.Instance)call sites to use the new parameterless constructor.IMessageSink/IMessageSinkMessagexUnit global-using aliases fromCli.UnitTests,TemplateSearch.Common.UnitTests,Utils.UnitTests.global using ITestOutputHelper = Xunit.ITestOutputHelper;aliases from projects that don't compile the shared CommandUtils sources (Orchestrator.RunnableProjects.UnitTests,IDE.IntegrationTests,Authoring.CLI.UnitTests,Authoring.CLI.IntegrationTests,TemplateSearch.TemplateDiscovery.IntegrationTests,Authoring.Templates.IntegrationTests).Authoring.Tasks.IntegrationTestsdoes link the sharedsrc/TemplateEngine/Tools/SharedCommandUtils sources, which referenceITestOutputHelperby its short name. Repointed its alias to the runner-agnosticMicrosoft.NET.TestFramework.ITestOutputHelperand added a reference toMicrosoft.NET.TestFramework.MSTest, so it compiles with no xUnit dependency.Validation
Built every in-scope project with the repo SDK in
Debug— all 0 warnings / 0 errors: TestHelper, Mocks, Core/Edge/Orchestrator/Utils/TemplateSearch.Common/TemplateLocalizer.Core unit tests, Cli.UnitTests, Authoring.CLI/Templates/Tasks/TemplateVerifier and IDE/TemplateDiscovery integration tests.Notes / out of scope
test/Microsoft.NET.TestFramework/**(legacy, xUnit-coupled) andtest/Microsoft.NET.TestFramework.MSTest/**were left untouched (the latter is only referenced).Xunittext in scope is non-functional: doc-comment URLs,#pragma warning disable xUnit1004suppression directives, incidental comments, and thesample05Verify snapshot asset (template-generated output captured as test data —sample05.Test/MyTest.cs+ its.csproj), which intentionally contains xUnit because it represents what the template emits.Cli.UnitTestskeeps itsMicrosoft.NET.TestFramework(legacy) reference — that reference exists for theMicrosoft.NET.TestFrameworkglobal usings, not for the (now-removed)IMessageSink, so it was left in place.Co-authored-by: Copilot [email protected]