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
🤖 Test Improver — automated AI assistant focused on improving tests for this repository.
Goal & Rationale
LoggingManager is the central class responsible for building the ILoggerFactory used throughout Microsoft.Testing.Platform. Despite its critical role in the logging pipeline, it had zero unit tests. This PR adds 9 focused tests covering all meaningful branches.
Approach
The tests exercise LoggingManager directly (it's internal, accessible via InternalsVisibleTo). Mocks are created with Moq for the external dependencies (IMonitor, IServiceProvider, ILoggerProvider, IExtension, IAsyncInitializableExtension). Multi-interface provider types are expressed as internal interface combinations so Moq can create a single mock implementing all required interfaces.
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 25265145801 -n agent -D /tmp/agent-25265145801
# Create a new branch
git checkout -b test-assist/logging-manager-buildAsync-tests-7351033ae996670b
# Apply the patch (--3way handles cross-repo patches where files may already exist)
git am --3way /tmp/agent-25265145801/aw-test-assist-logging-manager-buildasync-tests.patch
# Push the branch to origin
git push origin test-assist/logging-manager-buildAsync-tests-7351033ae996670b
# Create the pull request
gh pr create --title '[Test Improver] Add unit tests for LoggingManager.BuildAsync' --base main --head test-assist/logging-manager-buildAsync-tests-7351033ae996670b --repo microsoft/testfx
Show patch preview (180 of 180 lines)
From ae56d09e1a8f74bdee885913817aee6b14f3a5b5 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sun, 3 May 2026 00:10:15 +0000
Subject: [PATCH] test: add unit tests for LoggingManager.BuildAsync
Cover all key behaviors of LoggingManager:
- AddProvider with null throws ArgumentNullException- BuildAsync with no providers returns a non-null factory- Factory delegate receives the correct LogLevel and IServiceProvider- Non-IExtension provider is always included- IExtension provider enabled -> included; disabled -> excluded- IAsyncInitializableExtension + enabled -> InitializeAsync called- IAsyncInitializableExtension + disabled -> InitializeAsync not called- Non-extension IAsyncInitializableExtension -> InitializeAsync called
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
.../Logging/LoggingManagerTests.cs | 149 ++++++++++++++++++
1 file changed, 149 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..cab4910
--- /dev/null+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs@@ -0,0 +1,149 @@+// 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 Lo
... (truncated)
🤖 Test Improver — automated AI assistant focused on improving tests for this repository.
Goal & Rationale
LoggingManageris the central class responsible for building theILoggerFactoryused throughout Microsoft.Testing.Platform. Despite its critical role in the logging pipeline, it had zero unit tests. This PR adds 9 focused tests covering all meaningful branches.Approach
The tests exercise
LoggingManagerdirectly (it'sinternal, accessible viaInternalsVisibleTo). Mocks are created with Moq for the external dependencies (IMonitor,IServiceProvider,ILoggerProvider,IExtension,IAsyncInitializableExtension). Multi-interface provider types are expressed asinternal interfacecombinations so Moq can create a single mock implementing all required interfaces.Tests added (
LoggingManagerTests.cs)AddProvider_NullFactory_ThrowsArgumentNullExceptionAddProviderBuildAsync_NoProviders_ReturnsNonNullFactoryBuildAsync_PassesCorrectLogLevelAndServiceProviderToFactoryLogLevelandIServiceProviderpassed toBuildAsyncBuildAsync_NonExtensionProvider_IsAlwaysIncludedILoggerProvider(notIExtension) is always added to the factoryBuildAsync_EnabledExtensionProvider_IsIncludedIExtension.IsEnabledAsync() == true→ provider includedBuildAsync_DisabledExtensionProvider_IsExcludedIExtension.IsEnabledAsync() == false→ provider skippedBuildAsync_InitializableExtensionProvider_WhenEnabled_CallsInitializeAsyncIAsyncInitializableExtensionhasInitializeAsynccalledBuildAsync_InitializableExtensionProvider_WhenDisabled_DoesNotCallInitializeAsyncIAsyncInitializableExtension→InitializeAsyncnever calledBuildAsync_NonExtensionInitializableProvider_CallsInitializeAsyncIAsyncInitializableExtension(noIsEnabledAsyncguard) →InitializeAsyncalways calledCoverage Impact
Test Status
✅ All 18 tests pass (9 per TFM):
Trade-offs
internal interfacehelpers defined at the bottom of the test file for multi-interface mocks — lightweight and keep the test code cleanLoggingManager(internal), avoiding integration overheadNote
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 (180 of 180 lines)