Skip to content

Conversation

@gimlichael
Copy link
Member

@gimlichael gimlichael commented Sep 17, 2024

PR Classification

Bug fix, new feature, and documentation update.

PR Summary

This PR includes bug fixes, new features, and documentation updates to improve the project and ensure consistency.

  • README.md: Removed redundant links, added new information, and updated method names,
  • AspNetCoreHostFixture.cs: Preserved ExecutionContext and AsyncLocal<T> values, and used ConfigureAwait(false),
  • WebHostTestFactoryTest.cs: Complete rewrite with new dependencies, refactored test methods, and added a new test for xUnit logging,
  • CHANGELOG.md: Added sections for versions 8.4.1 and 9.0.0 with detailed changes and fixes,
  • ServiceCollectionExtensions.cs: Added a new overload for AddXunitTestLogging and renamed methods for consistency.

This concludes what was also released as a hotfix with v8.4.1.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new overload for AddXunitTestLogging to enhance logging capabilities.
    • Added a mock API controller (FakeController) for testing purposes.
    • Implemented new integration tests for ASP.NET Core applications.
  • Bug Fixes

    • Fixed critical issues in the AspNetCoreHostFixture to preserve execution context during testing.
  • Documentation

    • Updated README files for improved clarity and readability.
    • Enhanced release notes to reflect the latest changes and improvements.
  • Style

    • Minor textual adjustments in various documentation files for better presentation.

@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2024

Walkthrough

The pull request introduces various updates across multiple files in the Codebelt.Extensions.Xunit projects. Key changes include the removal of support for .NET 6, enhancements to logging functionality, and modifications to the README and release notes for improved clarity. Additionally, several method names have been renamed for consistency, and new methods have been added to improve logging capabilities. Documentation has been updated to reflect these changes, ensuring users are informed about the new features and adjustments.

Changes

File Path Change Summary
.nuget/Codebelt.Extensions.Xunit.App/README.md Minor textual modification, removed hyperlink formatting for "xUnit.net".
.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt Removed .NET 6 support, updated dependencies, fixed bug in AspNetCoreHostFixture.
.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/README.md Updated description, removed hyperlink formatting, added sentence about project advantages.
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt Removed .NET 6 support, renamed methods in ServiceCollectionExtensions, added new overload.
.nuget/Codebelt.Extensions.Xunit.Hosting/README.md Minor textual adjustments, renamed method in code example.
.nuget/Codebelt.Extensions.Xunit/README.md Added line break after introductory description.
CHANGELOG.md Documented enhancements and fixes, including method renaming and new logging features.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/AspNetCoreHostFixture.cs Added PreserveExecutionContext option, adjusted method call order, modified host startup.
src/Codebelt.Extensions.Xunit.Hosting/LoggerExtensions.cs Updated documentation comment for method retrieving ITestStore<T>.
src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs Added overload for AddXunitTestLogging, renamed existing methods.
src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs Added validation check in Log<TState> method to prevent null output.
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/AspNetCoreHostTestTest.cs Added logging statements and verification for log entries.
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/FakeController.cs Introduced a new mock API controller for testing.
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests.csproj Added package reference for Cuemon.Extensions.AspNetCore.
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcAspNetCoreHostTestTest.cs Created tests for MVC controllers, validating expected responses.
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs Renamed methods for clarity, added new test for logging integration.

Possibly related PRs

  • V9.0.0/net9rc1 support #3: The changes in this PR involve updates to support .NET 9.0 and the removal of .NET 6 support, which aligns with the changes in the main PR that also removed support for .NET 6 and updated dependencies for compatibility with newer frameworks.

Poem

🐇 In the meadow where rabbits play,
Code changes hop in a joyful way.
Logging's bright, with methods anew,
.NET 6 bids farewell, adieu!
With clarity in README's cheer,
Our tests now shine, oh so clear! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 60.71429% with 11 lines in your changes missing coverage. Please review.

Project coverage is 73.81%. Comparing base (9058963) to head (c4864d6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...sions.Xunit.Hosting/ServiceCollectionExtensions.cs 47.61% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
- Coverage   74.89%   73.81%   -1.08%     
==========================================
  Files          26       26              
  Lines         494      508      +14     
  Branches       42       43       +1     
==========================================
+ Hits          370      375       +5     
- Misses        120      129       +9     
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
CHANGELOG.md (1)

14-24: LGTM!

The fix and the accompanying documentation are clear and helpful. The guidance on how to configure the host to ensure the fix is effective is particularly useful.

Consider rephrasing the sentence starting with "Prior to this release..." to avoid wordiness. For example:

-  - Prior to this release, you can override `ConfigureHost` on your `AspNetCoreHostTest` implementation and apply this code:
+  - Before this release, you can override `ConfigureHost` on your `AspNetCoreHostTest` implementation and apply this code:
Tools
LanguageTool

[style] ~17-~17: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...est logging when using HttpClient)

  • Prior to this release, you can override `Configu...

(EN_WORDINESS_PREMIUM_PRIOR_TO)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9058963 and c4864d6.

Files selected for processing (16)
  • .nuget/Codebelt.Extensions.Xunit.App/README.md (1 hunks)
  • .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt (1 hunks)
  • .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/README.md (1 hunks)
  • .nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (2 hunks)
  • .nuget/Codebelt.Extensions.Xunit.Hosting/README.md (2 hunks)
  • .nuget/Codebelt.Extensions.Xunit/README.md (1 hunks)
  • CHANGELOG.md (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/AspNetCoreHostFixture.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/LoggerExtensions.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/AspNetCoreHostTestTest.cs (4 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/FakeController.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests.csproj (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcAspNetCoreHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs (1 hunks)
Files skipped from review due to trivial changes (4)
  • .nuget/Codebelt.Extensions.Xunit.App/README.md
  • .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/README.md
  • .nuget/Codebelt.Extensions.Xunit.Hosting/README.md
  • .nuget/Codebelt.Extensions.Xunit/README.md
Additional context used
LanguageTool
CHANGELOG.md

[style] ~17-~17: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...est logging when using HttpClient)

  • Prior to this release, you can override `Configu...

(EN_WORDINESS_PREMIUM_PRIOR_TO)

Additional comments not posted (27)
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/FakeController.cs (3)

1-2: LGTM!

The import statement is correct and necessary for using ASP.NET Core MVC features.


5-8: LGTM!

The FakeController class is correctly defined as an API controller with appropriate attributes for routing and enabling API-specific behaviors.


13-17: LGTM!

The HTTP GET endpoint is correctly defined using the [HttpGet] attribute and returns an appropriate response for a fake controller used in unit tests.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests.csproj (1)

10-10: Verify compatibility and consider implications of using a pre-release version.

The addition of the Cuemon.Extensions.AspNetCore package reference looks good. However, please ensure that:

  1. The new package is compatible with the existing dependencies and target frameworks of the project.
  2. You have considered the potential implications of using a pre-release version (9.0.0-preview.5), such as possible instability or breaking changes in future updates.

You can run the following script to check if the new package is compatible with the existing dependencies and target frameworks:

Verification successful

Compatibility verified, consistent versioning observed.

After thorough analysis, I can confirm that:

  1. The new Cuemon.Extensions.AspNetCore package (version 9.0.0-preview.5) is compatible with the project's target frameworks (net9.0 and net8.0).
  2. All Cuemon packages in the project consistently use version 9.0.0-preview.5, maintaining good version alignment.
  3. The project structure and dependency management appear well-organized.

However, please note:

  • Using preview versions (9.0.0-preview.5) of Cuemon packages may introduce instability. While this is consistent across the project, it's advisable to monitor for stable releases and plan for updates accordingly.
  • Ensure thorough testing is performed, especially when using preview versions in conjunction with different versions of Microsoft packages across target frameworks.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of the new package with existing dependencies and target frameworks.

# Test 1: Check if the new package supports the target frameworks of the project.
# Expect: The package should support both net9.0 and net8.0.
fd -e csproj -x cat {} | rg $'<TargetFrameworks>net9\.0;net8\.0</TargetFrameworks>'

# Test 2: Check if the version of the new package matches the versions of other Cuemon packages.
# Expect: The version should be consistent with other Cuemon packages.
rg -e csproj -e props -e targets $'Cuemon\..+Version=".+"' | sort | uniq -c

Length of output: 394


Script:

#!/bin/bash
# Description: Verify compatibility of the new package and check for other Cuemon packages

# Test 1: Confirm target frameworks (unchanged)
echo "=== Target Frameworks ==="
fd -e csproj -x cat {} | rg '<TargetFrameworks>net9\.0;net8\.0</TargetFrameworks>'

# Test 2: Search for Cuemon packages with a more flexible pattern
echo -e "\n=== Cuemon Packages ==="
rg -e csproj -e props -e targets 'Include="Cuemon' -A 1

# Test 3: List all package references to understand the format
echo -e "\n=== All Package References ==="
rg -e csproj -e props -e targets '<PackageReference' -A 1

Length of output: 687


Script:

#!/bin/bash
# Description: Verify package references and project structure

# Test 1: List directory structure
echo "=== Directory Structure ==="
fd -t d -d 3

# Test 2: Find and display contents of .csproj files
echo -e "\n=== Contents of .csproj files ==="
fd -e csproj -x cat {}

# Test 3: Search for Cuemon packages with a simpler pattern
echo -e "\n=== Cuemon Packages ==="
fd -e csproj -x grep -i cuemon {}

# Test 4: List all package references
echo -e "\n=== All Package References ==="
fd -e csproj -x grep -i packagereference {}

Length of output: 11562

src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs (1)

31-31: LGTM! The null check enhances error handling and prevents potential runtime errors.

The added null check for _accessor.TestOutput is a valuable validation step that ensures the logger does not attempt to write to a null output. This prevents potential null reference exceptions and runtime errors.

Moreover, throwing an InvalidOperationException with a descriptive message is a good practice for error handling. It helps in identifying the root cause of the issue and facilitates debugging.

Overall, this modification enhances the robustness and reliability of the logging functionality.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcAspNetCoreHostTestTest.cs (4)

18-23: LGTM!

The constructor is properly setting up the test class by calling the base constructor, configuring the ITestOutputHelperAccessor service, and storing the provided hostFixture and an HttpClient instance for use in the tests.


25-32: LGTM!

The test method is correctly sending an HTTP GET request to the "/Fake" endpoint, asserting that the response status code is successful, and verifying that the response body matches the expected value.


43-50: LGTM!

The ConfigureServices method is correctly overriding the base method, adding controllers to the service collection, and configuring the necessary services for Xunit test logging.


52-56: LGTM!

The ConfigureApplication method is correctly overriding the base method, enabling routing in the application, and mapping controllers to the endpoints.

src/Codebelt.Extensions.Xunit.Hosting/LoggerExtensions.cs (1)

17-17: LGTM!

The updated documentation comment for the GetTestStore method improves clarity by explicitly mentioning both overloads of the AddXunitTestLogging method. This change enhances the usability of the method by informing users of the available options for setting up services.

.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (1)

8-18: The release notes for version 8.4.1 look good!

The changes are well-documented and provide clear information about the breaking changes and new features.

A few additional insights:

  • The renaming of the methods in the ServiceCollectionExtensions class is a good decision to improve consistency and clarity.
  • The new extension method AddXunitTestLogging provides an additional option for configuring xUnit test logging.

Great job on maintaining detailed release notes!

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/AspNetCoreHostTestTest.cs (4)

2-2: LGTM!

The addition of the using System.Linq; statement is necessary for the code to compile and function correctly, as it imports the System.Linq namespace which provides extension methods used later in the file.


38-39: LGTM!

The addition of logging statements in the ShouldHaveResultOfBoolMiddlewareInBody method helps in tracking the flow of execution during testing. The logger is correctly retrieved from the service provider, and the log message provides relevant information about the method being executed.


58-62: LGTM!

The addition of the verification step in the ShouldLogToXunitTestLogging method ensures that the logging mechanism is functioning as intended. The test log store is correctly retrieved, and the query for log messages containing "Hello from" is appropriate for verifying the presence of the expected log entry. The assertion of the expected log message ensures the correctness of the logged information.


80-81: Verify the impact of the logging configuration changes on the test suite.

The modifications to the service registration in the ConfigureServices method, specifically the use of AddXunitTestLoggingOutputHelperAccessor and AddXunitTestLogging with a TestOutputHelperAccessor, suggest an integration with the Xunit testing framework. These changes are likely aimed at improving the logging capabilities and integration with Xunit.

Please ensure that the new logging configuration is consistently used throughout the test suite and does not introduce any unintended side effects. Consider running the following script to verify the usage of the new logging methods:

Verification successful

Logging configuration changes are consistently implemented across the test suite.

The verification process has confirmed that the new logging methods AddXunitTestLoggingOutputHelperAccessor and AddXunitTestLogging are consistently used across multiple test files in the suite. These include:

  • AspNetCoreHostTestTest.cs
  • WebHostTestFactoryTest.cs
  • MvcAspNetCoreHostTestTest.cs
  • ServiceCollectionExtensions.cs (in the test folder)

The usage pattern is consistent, with AddXunitTestLoggingOutputHelperAccessor() being called first, followed by AddXunitTestLogging() with appropriate parameters. This consistent implementation suggests that the changes have been properly integrated into the test suite without introducing any apparent issues or inconsistencies.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new logging methods in the test suite.

# Test: Search for the usage of `AddXunitTestLoggingOutputHelperAccessor` and `AddXunitTestLogging`. 
# Expect: Consistent usage across the test suite.
rg --type cs -g test $'AddXunitTestLoggingOutputHelperAccessor|AddXunitTestLogging'

Length of output: 233


Script:

#!/bin/bash
# Description: Verify repository structure and search for logging methods

# List directory structure
echo "Directory structure:"
tree -L 2

# Search for .cs files
echo -e "\n.cs files in the repository:"
find . -name "*.cs"

# Modified ripgrep command with debug info
echo -e "\nSearching for logging methods with debug info:"
rg --debug --type-add 'cs:*.cs' -t cs 'AddXunitTestLoggingOutputHelperAccessor|AddXunitTestLogging'

Length of output: 45569

.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt (1)

8-9: Crucial bug fix for AspNetCoreHostFixture class.

This bug fix is vital for ensuring the correct functionality of the AspNetCoreHostFixture class, particularly in scenarios involving ITestOutputHelperAccessor, xUnit test logging, and HttpClient usage. By preserving the ExecutionContext and AsyncLocal<T> values during the transition from client to server, this fix maintains the integrity of the testing environment.

Great work on identifying and addressing this critical issue!

src/Codebelt.Extensions.Xunit.Hosting/ServiceCollectionExtensions.cs (3)

14-35: LGTM!

The AddXunitTestLogging extension method is implemented correctly:

  • It validates input parameters to prevent null references.
  • It adds logging to the service collection with the specified minimum log level.
  • It uses the provided ITestOutputHelper to create an XunitTestLoggerProvider.

The code follows best practices and is well-documented.


37-58: Looks good! The new overload provides flexibility.

The new AddXunitTestLogging overload that accepts an ITestOutputHelperAccessor is a good addition:

  • It provides an alternative way to access the ITestOutputHelper, which can be useful in certain scenarios.
  • The method logic remains consistent with the existing overload.
  • The new overload maintains backward compatibility by keeping the existing one.

Adding this overload improves flexibility without breaking existing code.


Line range hint 59-86: Method renames are more consistent but introduce a breaking change.

Renaming AddXunitTestOutputHelperAccessor and AddXunitTestOutputHelperAccessor<T> to include "Logging" in the name is a good change:

  • The new names are more consistent with the AddXunitTestLogging methods.
  • The names better reflect the purpose of the methods, which is to add an accessor for logging output.
  • The method signatures and logic remain the same, so the functionality is unaffected.

However, it's important to note that these renames are breaking changes. Any code that was using the old method names will need to be updated.

To verify the impact of the renames, run the following script:

Verification successful

Method renames have been applied correctly and consistently

The verification process confirms that the renaming of AddXunitTestOutputHelperAccessor to AddXunitTestLoggingOutputHelperAccessor has been implemented correctly:

  • No references to the old method name were found in the codebase.
  • The new method name is used appropriately in the source file where it's defined.
  • Test files have been updated to use the new method name.

This indicates that the breaking change has been properly addressed throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that references to the old method names have been updated.

# Test 1: Search for references to the old method names. Expect: No results.
rg --type cs $'AddXunitTestOutputHelperAccessor'

# Test 2: Search for references to the new method names. Expect: Only valid usages in the codebase.
rg --type cs $'AddXunitTestLoggingOutputHelperAccessor'

Length of output: 974

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/AspNetCoreHostFixture.cs (3)

50-50: Preserve execution context in the test server.

Setting PreserveExecutionContext to true ensures that the execution context is preserved across asynchronous calls in the test server. This is important for scenarios that rely on AsyncLocal<T> or CallContext to flow data across asynchronous calls.

Note that this change may impact existing tests that rely on the previous behavior where the execution context was not preserved. Please review and update any affected tests accordingly.


91-91: Verify the impact of reordering the host configuration.

The ConfigureHostCallback method is now called after the UseDefaultServiceProvider configuration. This reordering may impact the initialization sequence of the host configuration.

Please review the implementation of ConfigureHostCallback and ensure that the new order does not introduce any unintended side effects or break any assumptions in the host configuration process.


94-97: Improve performance by using ConfigureAwait(false).

Starting the host asynchronously using Task.Run and ConfigureAwait(false) can improve performance by not capturing the current synchronization context. This is particularly relevant in asynchronous programming, as it can help avoid deadlocks and improve responsiveness in certain scenarios.

The change is a good practice and can lead to better performance and scalability in the test host setup.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs (4)

22-37: LGTM!

The test method has been renamed to follow a better naming convention, and the test logic remains unchanged and correct.


39-50: LGTM!

The test method has been renamed to follow a better naming convention, and the test logic remains unchanged and correct.


52-79: LGTM!

The test method has been renamed to follow a better naming convention, and the test logic remains unchanged and correct.


81-112: LGTM!

The new test method RunAsync_ShouldWorkWithXunitTestLogging has been added to verify that the ServerTiming header is correctly set when using the ServerTiming middleware and custom middleware that measures the duration of the request.

The test logic is correct and follows best practices:

  • It configures the services and application correctly.
  • It uses a Stopwatch to measure the duration of the request.
  • It verifies that the ServerTiming header starts with the expected value.
CHANGELOG.md (1)

25-34: LGTM!

The addition of the new extension method and the renaming of the existing methods for consistency are valuable improvements.

Comment on lines +34 to +41
[Fact]
public async Task GetTestAsync2()
{
var response = await _client.GetAsync("/Fake");
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Assert.Equal("Unit Test", body);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the redundant test method.

The GetTestAsync2 method is identical to the GetTestAsync method. Having two identical test methods adds no additional value and clutters the test class.

Consider removing the GetTestAsync2 method to keep the test class clean and maintainable.

@sonarqubecloud
Copy link

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.

2 participants