Uh oh!
There was an error while loading. Please reload this page.
[Test Improver] test: add unit tests for LoggingManager.BuildAsync and ExtensionValidationHelper.ValidateUniqueExtension - #8127
Conversation
…ationHelper.ValidateUniqueExtension Adds 10 tests for LoggingManager.BuildAsync covering: - No providers case - Non-extension provider inclusion - Extension provider enabled/disabled filtering - IAsyncInitializableExtension initialization - Multiple providers handling - Factory receives correct log level and service provider Adds 16 tests for ExtensionValidationHelper.ValidateUniqueExtension covering: - Null argument validation for both overloads - Empty collection (no-throw) - No-duplicate case (no-throw) - Single and multiple duplicates (throw) - Error message content (uid and type names) - Custom selector overload Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds new unit tests to improve regression coverage for two internal helpers in Microsoft.Testing.Platform: LoggingManager.BuildAsync (provider filtering/initialization behavior) and ExtensionValidationHelper.ValidateUniqueExtension (UID uniqueness enforcement).
Changes:
- Added
LoggingManagerTestscovering provider inclusion/exclusion, async initialization, and factory callback inputs (log level + service provider). - Added
ExtensionValidationHelperTestscovering null-guards, no-duplicate scenarios, duplicate detection, and error message content (UID + type list).
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/LoggingManagerTests.cs | New tests for LoggingManager.BuildAsync branching behavior and provider factory inputs. |
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/ExtensionValidationHelperTests.cs | New tests for ValidateUniqueExtension overloads, including duplicates + message validation. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Amaury Levé (Evangelink)
left a comment
There was a problem hiding this comment.
Summary
Workflow: Expert Code Reviewer
Date: 2026-05-11
Repository: microsoft/testfx
Key Findings
No actionable issues found. The new unit tests are correct and well-structured.
Correctness ✅ — Each test accurately targets the corresponding production code path:
LoggingManagerTestscorrectly distinguishes between non-extension, enabled-extension, disabled-extension, and initializable providers. The helper interface definitions (IEnabledLoggerProvider : ILoggerProvider, IExtension,IInitializableLoggerProvider : ILoggerProvider, IAsyncInitializableExtension,IEnabledInitializableLoggerProvider : ILoggerProvider, IExtension, IAsyncInitializableExtension) at the bottom of the file map precisely to the conditional branches inLoggingManager.BuildAsync.ExtensionValidationHelperTestscorrectly verifies both overloads, null-argument guards, empty-collection no-throw, UID-duplicate detection, error message content (including dynamic proxy type names from Moq, which match how the production code usesx.GetType()), and the custom-selector overload.
Threading / Concurrency ✅ — IMonitor.Lock is properly mocked to return an IDisposable; LoggerFactory.CreateLogger uses it for thread-safe dictionary access. Tests are isolated (fresh LoggingManager per test method) with no shared mutable state.
Resources ✅ — No IDisposable/IAsyncDisposable objects introduced in tests that require explicit cleanup.
Test infrastructure ✅ — Moq is an established dependency in the test project; DynamicProxyGenAssembly2 is granted InternalsVisibleTo access, so mocking internal interfaces works correctly.
Positive Observations
- Test helper interface definitions are concise and placed at the file scope (not nested), which is idiomatic for this codebase.
Assert.ThrowsExactly<T>is used rather thanAssert.ThrowsException<T>, which is the correct precision for exception-type assertions.- Assertions on error message content use the same
GetType().ToString()expression the production code uses, making them robust against Moq proxy type names.
Recommendations
No changes required.
Generated by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
Amaury Levé (Evangelink)
left a comment
There was a problem hiding this comment.
Summary
Workflow: Test Expert Reviewer 🧪
Date: 2026-05-11
Repository: microsoft/testfx
Key Findings
[Assertion] Vacuous type-name assertions in
ErrorMessageContainsTypeNamestests (ExtensionValidationHelperTests.cs, lines 95-96 and 206-207)
BothMock<IExtension>instances share the same Moq-generated proxy type at runtime, making the twoAssert.Contains(x.GetType().ToString(), ...)calls identical. The tests pass even if only one type name (or neither, in a degenerate case) appears in the error message. Using concreteIExtensionimplementations with distinct type names would make each assertion independently meaningful.[Coverage] Missing "enabled + initializable" test in
LoggingManagerTests(LoggingManagerTests.cs)
The disabled+initializable case is tested (BuildAsync_DisabledExtensionAndInitializable_InitializeAsyncIsNotCalled), but the affirmative complement — an enabledIExtensionthat is alsoIAsyncInitializableExtensionshould haveInitializeAsynccalled — is missing. The existingBuildAsync_InitializableProvider_InitializeAsyncIsCalleduses a provider that is not anIExtensionat all, so it exercises a different code path.
Strengths
- Good overall coverage of
LoggingManager.BuildAsyncscenarios (no-providers, non-extension, enabled/disabled extension, mixed). - Guard-clause tests (
ArgumentNullExceptionpaths) for both overloads ofValidateUniqueExtensionare thorough. - Correct use of MSTest assertions throughout (consistent with the project's BannedSymbols policy).
- Helper interfaces (
IEnabledLoggerProvider,IInitializableLoggerProvider,IEnabledInitializableLoggerProvider) are a clean pattern for constructing typed mocks.
Generated by Test Expert Reviewer
🧪 Test quality reviewed by Test Expert Reviewer 🧪
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Amaury Levé (Evangelink)
commented
May 11, 2026
Copilot address review comments |
Amaury Levé (Evangelink)
left a comment
There was a problem hiding this comment.
Summary
Workflow: PR Nitpick Reviewer 🔍
Date: 2026-05-11
Repository: microsoft/testfx
Key Findings
[Important] Duplicate Arrange+Act in adjacent test pairs — Both
ExtensionValidationHelperTestssections (GenericandSimple) have pairs of tests (ThrowsInvalidOperationException+ErrorMessageContainsTypeNames) with completely identical setup and method invocation, differing only in assertions. Extracting a shared helper that returns the exception would eliminate the duplication.[Important] Asymmetric test coverage — The
Genericoverload section coversMultipleDuplicatesbut theSimpleoverload section does not, leaving a potential regression path untested.[Minor] Named
mockLoggervariables never verified — InBuildAsync_NonExtensionProvider_IsAlwaysIncludedandBuildAsync_EnabledExtensionProvider_IsIncluded, a namedMock<ILogger>is used only to satisfy aReturns()call. UsingMock.Of<ILogger>()inline better communicates intent.[Minor] Single-character variable name inside multi-line lambda — The
BuildAsync_FactoryReceivesCorrectLogLevellambda usespfor an internal mock, inconsistent with the descriptive names (mockProvider, etc.) used elsewhere.
Positive Highlights
- Excellent test structure overall: clear naming, logical grouping with section comments, and good coverage of null-argument edge cases.
- Good use of
Assert.ThrowsExactly<T>(overThrowsException) for precise exception-type checks. - The helper interfaces (
IEnabledLoggerProvider,IInitializableLoggerProvider,IEnabledInitializableLoggerProvider) are well-designed to isolate specific code paths inLoggingManager.BuildAsync.
Generated by PR Nitpick Reviewer
🔍 Meticulously inspected by PR Nitpick Reviewer 🔍
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Done in |
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Addressed in |
Amaury Levé (Evangelink)
commented
May 11, 2026
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Resolved in |
Amaury Levé (Evangelink)
commented
May 12, 2026
Note The pull request was not created — a fallback review issue was created instead due to protected file changes: #8140 🤖 Test Improver here. Status update: the work in this PR has been superseded. The LoggingManager tests landed in main via #8124 and #8130, and the ExtensionValidationHelper tests landed via #8128. This PR is a duplicate and can be safely closed.
|
Amaury Levé (Evangelink)
commented
May 13, 2026
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Resolved in |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.