You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 This PR was created by Test Improver, an automated AI assistant focused on improving tests.
Goal and Rationale
LoggingManager.BuildAsync orchestrates the initialization of all registered ILoggerProvider instances. Its core logic — filtering disabled extensions, calling TryInitializeAsync, and assembling the resulting LoggerFactory — was previously untested.
The patch file is available in the agent artifact in the workflow run linked above.
To create a pull request with the changes:
# Download the artifact from the workflow run
gh run download 25238451326 -n agent -D /tmp/agent-25238451326
# Create a new branch
git checkout -b test-assist/logging-manager-tests-2026-05-02-b508f356a07ba0b9
# Apply the patch (--3way handles cross-repo patches where files may already exist)
git am --3way /tmp/agent-25238451326/aw-test-assist-logging-manager-tests-2026-05-02.patch
# Push the branch to origin
git push origin test-assist/logging-manager-tests-2026-05-02-b508f356a07ba0b9
# Create the pull request
gh pr create --title '[Test Improver] Add unit tests for LoggingManager.BuildAsync' --base main --head test-assist/logging-manager-tests-2026-05-02-b508f356a07ba0b9 --repo microsoft/testfx
Show patch preview (167 of 167 lines)
From eb5b96a1843e0ddf3b4c5b03107233b9456f3e72 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sat, 2 May 2026 00:16:25 +0000
Subject: [PATCH] Add unit tests for LoggingManager.BuildAsync
Tests cover:
- AddProvider(null) throws ArgumentNullException- BuildAsync with no providers returns empty factory- Factory delegate receives correct LogLevel and IServiceProvider- Non-IExtension provider is always included- Enabled IExtension provider is included- Disabled IExtension provider is excluded- IAsyncInitializableExtension provider has InitializeAsync called- Disabled IAsyncInitializableExtension provider does not have InitializeAsync called
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
.../Logging/LoggingManagerTests.cs | 136 ++++++++++++++++++
1 file changed, 136 insertions(+)
create mode 100644 test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs
diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs
new file mode 100644
index 0000000..51f1257
--- /dev/null+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs@@ -0,0 +1,136 @@+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT license. See LICENSE file in the project root for full license information.++using Microsoft.Testing.Platform.Extensions;+using Microsoft.Testing.Platform.Helpers;+using Microsoft.Testing.Platform.Logging;++using Moq;++namespace Microsoft.Testing.Platform.UnitTests;++[TestClass]+public sealed class LoggingManagerTests+{+ private readonly Mock<IMonitor> _mockMonitor = new();+ private readonly Mock<IServiceProvider> _mockServiceProvider = new();++ public LoggingManagerTests()+ => _mockMonitor.Setup(x => x.Lock(It.IsAny<object>())).Re
... (truncated)
🤖 This PR was created by Test Improver, an automated AI assistant focused on improving tests.
Goal and Rationale
LoggingManager.BuildAsyncorchestrates the initialization of all registeredILoggerProviderinstances. Its core logic — filtering disabled extensions, callingTryInitializeAsync, and assembling the resultingLoggerFactory— was previously untested.Tests Added (8 tests × 2 TFMs = 16 total)
AddProvider_WithNullFactory_ThrowsArgumentNullExceptionAddProviderBuildAsync_WithNoProviders_ReturnsEmptyLoggerFactoryBuildAsync_PassesLogLevelAndServiceProviderToFactoryLogLevelandIServiceProviderBuildAsync_WithNonExtensionProvider_IncludesProviderILoggerProvideris always includedBuildAsync_WithEnabledExtensionProvider_IncludesProviderIExtension.IsEnabledAsync() == true→ includedBuildAsync_WithDisabledExtensionProvider_ExcludesProviderIExtension.IsEnabledAsync() == false→ excludedBuildAsync_WithInitializableProvider_CallsInitializeAsyncIAsyncInitializableExtension.InitializeAsync()calledBuildAsync_WithDisabledInitializableExtensionProvider_DoesNotCallInitializeAsyncInitializeAsyncTest Status
✅ All 8 new tests pass (net8.0, 0 warnings)
Reproducibility
Trade-offs
Low maintenance burden: tests use Moq (already a project dependency) and follow established patterns in the
Logging/test folder.Note
This was originally intended as a pull request, but the git push operation failed.
Workflow Run: View run details and download patch artifact
The patch file is available in the
agentartifact in the workflow run linked above.To create a pull request with the changes:
Show patch preview (167 of 167 lines)