Skip to content

Remove xUnit from TemplateEngine test helpers - #55067

Merged
Evangelink merged 3 commits into
mainfrom
dev/amauryleve/templateengine-xunit-migration
Jun 30, 2026
Merged

Evangelink merged 3 commits into
mainfrom
dev/amauryleve/templateengine-xunit-migration

Conversation

@Evangelink

Copy link
Copy Markdown
Member

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 the IXunitSerializable mock data classes. This removes all of it so the in-scope projects contain zero functional xUnit.

Scope: test/TemplateEngine/** and test/Microsoft.TemplateEngine.Cli.UnitTests/** only.

What changed

Helper libraries (Microsoft.NET.Sdk, not MSTest.Sdk)

  • Microsoft.TemplateEngine.TestHelper
    • XunitLoggerProvider → TestLoggerProvider: logs through a System.Action<string> write callback instead of xUnit's ITestOutputHelper.
    • Deleted SharedTestOutputHelper.cs (an Xunit.ITestOutputHelper wrapper around IMessageSink that emitted DiagnosticMessage).
    • EnvironmentSettingsHelper and TestLoggerFactory constructors now take an optional Action<string>? instead of Xunit.Sdk.IMessageSink?.
    • Removed the xunit.v3.extensibility.core PackageReference; updated PublicAPI.Unshipped.txt.
  • Microsoft.TemplateEngine.Mocks
    • Removed IXunitSerializable (and the Serialize/Deserialize members) from MockCreationEffects, MockFileChange, MockTemplateInfo. MSTest data sources don't need xUnit serialization.
    • Removed the xunit.v3.extensibility.core PackageReference.

Test projects

  • Deleted the 7 per-project NullMessageSink.cs no-op IMessageSink implementations and updated the ~53 new EnvironmentSettingsHelper(NullMessageSink.Instance) call sites to use the new parameterless constructor.
  • Removed the IMessageSink/IMessageSinkMessage xUnit global-using aliases from Cli.UnitTests, TemplateSearch.Common.UnitTests, Utils.UnitTests.
  • Removed the now-dead 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.IntegrationTests does link the shared src/TemplateEngine/Tools/Shared CommandUtils sources, which reference ITestOutputHelper by its short name. Repointed its alias to the runner-agnostic Microsoft.NET.TestFramework.ITestOutputHelper and added a reference to Microsoft.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

  • No shared/legacy framework files were modified. test/Microsoft.NET.TestFramework/** (legacy, xUnit-coupled) and test/Microsoft.NET.TestFramework.MSTest/** were left untouched (the latter is only referenced).
  • The only remaining Xunit text in scope is non-functional: doc-comment URLs, #pragma warning disable xUnit1004 suppression directives, incidental comments, and the sample05 Verify 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.UnitTests keeps its Microsoft.NET.TestFramework (legacy) reference — that reference exists for the Microsoft.NET.TestFramework global usings, not for the (now-removed) IMessageSink, so it was left in place.

Co-authored-by: Copilot [email protected]

Evangelink and others added 2 commits June 30, 2026 09:26
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]>
Copilot AI review requested due to automatic review settings June 30, 2026 07:27
@Evangelink
Evangelink requested a review from a team as a code owner June 30, 2026 07:27

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 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 an Action<string> callback-based logger provider/factory.
  • Remove IXunitSerializable from TemplateEngine mock data classes and delete per-project NullMessageSink shims.
  • Update TemplateEngine/Cli tests and global usings to compile without xUnit (including a runner-agnostic ITestOutputHelper alias 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
Evangelink enabled auto-merge June 30, 2026 10:03
@Evangelink
Evangelink merged commit 7f8e5c7 into main Jun 30, 2026
25 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/templateengine-xunit-migration branch June 30, 2026 10:05
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 1, 2026
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