-
Notifications
You must be signed in to change notification settings - Fork 1
V10.0.0/support for xunitlogger #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis pull request introduces new host fixture classes and interfaces in the Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Runner
participant SC as IServiceCollection
participant Ext as ServiceCollectionExtensions
participant LP as XunitTestLoggerProvider
T->>SC: Create service collection
SC->>Ext: Call AddXunitTestLogging (with or without ITestOutputHelper)
Ext->>SC: Configure logging (set minimum log level)
Ext->>LP: Add logging provider
LP-->>T: Handle logging via null-conditional operations
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (9)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- .nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt: Language not supported
- Directory.Packages.props: Language not supported
- testenvironments.json: Language not supported
Comments suppressed due to low confidence (1)
src/Codebelt.Extensions.Xunit.Hosting/XunitTestLoggerProvider.cs:15
- [nitpick] The parameterless constructor does not initialize _output or _accessor, which may cause confusion about its intended behavior. Consider adding an XML documentation comment or inline comment to clarify that this constructor is intentionally designed for scenarios where no test output is provided.
public XunitTestLoggerProvider()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/Codebelt.Extensions.Xunit.Hosting/XunitTestLoggerProvider.cs (1)
31-34: Consider adding null handling for scenario where both _accessor and _output are nullWhen instantiated with the default constructor, both
_accessorand_outputwill be null. The current implementation will try to use_outputwhen_accessoris null, which could lead to unexpected behavior. While the null-conditional operator in XunitTestLogger.Log handles this, it would be clearer to have explicit handling here.return _loggers.GetOrAdd(categoryName, _ => _accessor != null ? new XunitTestLogger(this, _accessor) - : new XunitTestLogger(this, _output)); + : new XunitTestLogger(this, _output ?? null));.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (1)
23-23: Minor grammatical issue in documentation.There's a subject-verb agreement issue. The verb "consist" should be "consists" since it refers to a singular class.
-ADDED MinimalHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace that consist of one extension method for the IMinimalHostFixture interface: HasValidState +ADDED MinimalHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace that consists of one extension method for the IMinimalHostFixture interface: HasValidState🧰 Tools
🪛 LanguageTool
[uncategorized] ~23-~23: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...Extensions.Xunit.Hosting namespace that consist of one extension method for the IMinima...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt(1 hunks)CHANGELOG.md(2 hunks)Directory.Packages.props(2 hunks)src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs(2 hunks)src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs(1 hunks)src/Codebelt.Extensions.Xunit.Hosting/XunitTestLoggerProvider.cs(1 hunks)test/Codebelt.Extensions.Xunit.Hosting.Tests/ServiceCollectionExtensions.cs(2 hunks)testenvironments.json(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (1)
Learnt from: gimlichael
PR: codebeltnet/xunit#17
File: src/Codebelt.Extensions.Xunit.Hosting/Codebelt.Extensions.Xunit.Hosting.csproj:22-26
Timestamp: 2025-04-07T16:28:51.830Z
Learning: In the `src/Codebelt.Extensions.Xunit.Hosting/Codebelt.Extensions.Xunit.Hosting.csproj` file, only certain .NET 8 packages are available in version 8.0.1, while others remain at 8.0.0, so package versions may differ due to availability.
🧬 Code Graph Analysis (1)
src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs (1)
src/Codebelt.Extensions.Xunit.Hosting/XunitTestLoggerProvider.cs (4)
XunitTestLoggerProvider(9-56)XunitTestLoggerProvider(15-17)XunitTestLoggerProvider(19-22)XunitTestLoggerProvider(24-27)
🪛 LanguageTool
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt
[uncategorized] ~23-~23: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...Extensions.Xunit.Hosting namespace that consist of one extension method for the IMinima...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: 🧪 Test (windows-2022, Release)
- GitHub Check: 📦 Pack (Debug)
- GitHub Check: 🧪 Test (windows-2022, Debug)
- GitHub Check: 🧪 Test (ubuntu-22.04, Release)
- GitHub Check: 🧪 Test (ubuntu-22.04, Debug)
- GitHub Check: 📦 Pack (Release)
🔇 Additional comments (13)
src/Codebelt.Extensions.Xunit.Hosting/XunitTestLoggerProvider.cs (1)
15-18: Default constructor added to support ITestOutputHelper-independent loggingThis new constructor enables the creation of a logger provider without requiring an ITestOutputHelper instance, aligning with the new overload of AddXunitTestLogging described in the changelog. This allows for logging configuration that avoids potential deadlocks with xUnit v2.
testenvironments.json (1)
12-12: Updated Docker image versionThe Docker image has been updated from
mono-net8.0.407-9.0.202tomono-net8.0.408-9.0.203, which likely includes newer versions of the .NET runtime and Mono framework for the test environment.src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs (1)
44-44: Improved null handling with null-conditional operatorThe addition of the null-conditional operator (
?.) prevents potentialNullReferenceExceptionwhen_outputis null, which complements the new default constructor in XunitTestLoggerProvider. This defensive programming approach improves robustness.CHANGELOG.md (3)
12-12: Updated version reference in changelogThe changelog now correctly references 9.1.x releases instead of 9.0.x, aligning with the version history documented below.
18-18: Clarified GenericHostFixture documentationThe documentation now explicitly states that GenericHostFixture replaces the legacy HostFixture class, providing clearer context for users migrating from previous versions.
34-35: Well-documented new AddXunitTestLogging overloadThe changelog clearly explains both what was added (the new overload) and why (to mitigate potential deadlocks with xUnit v2), providing valuable context for users. The reference to the GitHub discussion about the deadlock issue is particularly helpful.
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (2)
19-19: Approved new class documentation.The addition of the
GenericHostFixtureclass as a replacement for the legacyHostFixtureclass is well-documented and correctly reflects the changes in the codebase.
26-26: Approved extension method documentation.The documentation for the new extension method
AddXunitTestLoggingwithout dependency onITestOutputHelperis clear and accurately describes the improvement.test/Codebelt.Extensions.Xunit.Hosting.Tests/ServiceCollectionExtensions.cs (2)
18-21: Modified test to use new overload method.The test has been correctly updated to use the new overload of
AddXunitTestLogging()that doesn't require anITestOutputHelperparameter.
72-124: Good test coverage for both overloads.You've added a comprehensive test for the existing overload that takes an
ITestOutputHelperparameter. This ensures both methods are properly tested with the same verification logic, maintaining good test coverage.Directory.Packages.props (1)
10-10:❓ Verification inconclusive
Package versions updated appropriately.
The updates to package versions (from 9.0.3 to 9.0.4 for .NET 9 packages and from 8.0.14 to 8.0.15 for Microsoft.AspNetCore.TestHost) are consistent with maintaining compatibility with the latest releases.
Also applies to: 27-32, 40-40
🏁 Script executed:
#!/bin/bash # Check compatibility of updated package versions # Check if there are any known issues with these specific versions echo "Checking for any breaking changes or known issues in updated packages..." # Microsoft.Bcl.AsyncInterfaces 9.0.4 echo "Microsoft.Bcl.AsyncInterfaces 9.0.4:" curl -s "https://api.nuget.org/v3/registration5-semver1/microsoft.bcl.asyncinterfaces/index.json" | jq '.items[0].items[] | select(.catalogEntry.version=="9.0.4") | .catalogEntry.description' # Microsoft.Extensions.Configuration 9.0.4 echo "Microsoft.Extensions.Configuration 9.0.4:" curl -s "https://api.nuget.org/v3/registration5-semver1/microsoft.extensions.configuration/index.json" | jq '.items[0].items[] | select(.catalogEntry.version=="9.0.4") | .catalogEntry.description' # Microsoft.AspNetCore.TestHost 8.0.15 echo "Microsoft.AspNetCore.TestHost 8.0.15:" curl -s "https://api.nuget.org/v3/registration5-semver1/microsoft.aspnetcore.testhost/index.json" | jq '.items[0].items[] | select(.catalogEntry.version=="8.0.15") | .catalogEntry.description'Length of output: 1242
Attention: Further Verification Needed for Microsoft.AspNetCore.TestHost
- The update for Microsoft.Bcl.AsyncInterfaces 9.0.4 was confirmed via its catalog description.
- The query for Microsoft.Extensions.Configuration 9.0.4 produced no visible description—which may be due to metadata differences—but raises no immediate concern.
- The verification query for Microsoft.AspNetCore.TestHost 8.0.15 failed (jq reported “Cannot iterate over null”), indicating that the package metadata might use a different schema or the package details are unavailable via this query. Please verify manually that version 8.0.15 is published and stable in the NuGet feed.
File: Directory.Packages.props
Location: Lines 10 (also applies to 27–32, 40)<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.4" />The update to package versions appears consistent with keeping the dependencies up to date. However, please double-check the NuGet details for Microsoft.AspNetCore.TestHost 8.0.15 to ensure its validity.
src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs (2)
14-33: Well-implemented new overload that addresses deadlock risks.The new overload of
AddXunitTestLoggingwithout theITestOutputHelperparameter is a valuable addition that solves potential deadlock scenarios in xUnit v2. The implementation has:
- Complete XML documentation with proper parameter descriptions
- Appropriate null checks
- Consistent configuration with the existing overload
- Uses the parameterless constructor of
XunitTestLoggerProviderThis is particularly useful for scenarios where you need logging in tests but don't need the output to be sent to the xUnit test output.
46-72: Improved formatting in existing method.The code formatting changes to the existing
AddXunitTestLoggingmethod improve readability while maintaining functionality.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 93.89% 93.97% +0.08%
==========================================
Files 44 44
Lines 884 896 +12
Branches 121 123 +2
==========================================
+ Hits 830 842 +12
Misses 44 44
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



This pull request includes several changes to enhance the functionality and compatibility of the
Codebelt.Extensions.Xunit.Hostinglibrary, as well as updates to package versions and testing environments. The most important changes include the addition of a new logging extension method, updates to package versions, and improvements to the test environment.New Features and Enhancements:
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt: Added an overload ofAddXunitTestLoggingthat does not rely on theITestOutputHelperinterface.src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs: Added a new extension methodAddXunitTestLoggingto theIServiceCollectioninterface.CHANGELOG.md: Updated to reflect the addition of the newAddXunitTestLoggingmethod and its benefits.Package Version Updates:
Directory.Packages.props: Updated several package versions, includingMicrosoft.Bcl.AsyncInterfaces,Microsoft.Extensions.Configuration, andMicrosoft.AspNetCore.TestHost. [1] [2]Testing and Documentation:
test/Codebelt.Extensions.Xunit.Hosting.Tests/ServiceCollectionExtensions.cs: Added new tests to verify the functionality of the newAddXunitTestLoggingmethod.testenvironments.json: Updated the Docker image for the test environment to a newer version.Summary by CodeRabbit
New Features
Updates
Tests
TestOutputparameter.