Skip to content

V11.2.0/startup fix - #68

Merged
gimlichael merged 10 commits into
mainfrom
v11.2.0/startup-fix
Aug 4, 2026
Merged

V11.2.0/startup fix#68
gimlichael merged 10 commits into
mainfrom
v11.2.0/startup-fix

Conversation

@gimlichael

Copy link
Copy Markdown
Member

This pull request introduces new "managed" fixture types for both application and ASP.NET Core integration testing, shifting ownership of host startup to the application's real entry point. The new ManagedApplicationFixture<TEntryPoint> and ManagedWebApplicationFixture<TEntryPoint> provide an opt-in, deferred startup path, while the legacy blocking fixtures are now marked as obsolete for compatibility and will be removed or changed in the next major release. Documentation and examples have been updated to reflect these changes and guide users toward the new recommended patterns.

New Features:

  • Added ManagedApplicationFixture<TEntryPoint> and ManagedWebApplicationFixture<TEntryPoint> as opt-in, entrypoint-owned fixtures for application and ASP.NET Core tests, respectively. These fixtures allow the application's Main method to control startup, with host/server startup deferred until consumed by the test. (.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt [1] .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt [2] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md [3] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md [4]

Deprecations and Compatibility:

  • Marked BlockingManagedApplicationFixture<TEntryPoint> and BlockingManagedWebApplicationFixture<TEntryPoint> as obsolete compatibility fixtures; documentation and examples now direct users to the new managed fixtures for entrypoint-owned startup. These types are retained for the current minor release and will be removed or changed in the next major release. (.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt [1] .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt [2] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.BlockingManagedApplicationFixture%601.md [3] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebApplicationFixture%601.md [4]

Documentation and Guidance Updates:

  • Updated all relevant documentation, READMEs, and API reference files to describe the new managed fixtures, clarify the deferred startup behavior, and provide guidance on migration from the legacy blocking fixtures. (.docfx/api/namespaces/Codebelt.Extensions.Xunit.Hosting.md [1] [2] .docfx/api/namespaces/Codebelt.Extensions.Xunit.Hosting.AspNetCore.md [3] [4] [5] .nuget/Codebelt.Extensions.Xunit.Hosting/README.md [6] .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/README.md [7] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md [8] [9] [10]

Examples and API Reference:

  • Added and revised code examples for both new and legacy fixture types to demonstrate usage patterns, entrypoint-owned startup, and migration paths. (.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md [1] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md [2] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.BlockingManagedApplicationFixture%601.md [3] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.BlockingManagedWebApplicationFixture%601.md [4] .docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ApplicationHostFactory.md [5] [6] [7]

Release Notes:

  • Updated package release notes for both application and ASP.NET Core packages to summarize new features, changes, and deprecations. (.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt [1] .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt [2]

Introduces ManagedApplicationFixture and ManagedWebApplicationFixture for opt-in entrypoint-owned startup, enabling the application's Main method to own host configuration and lifecycle. Adds internal deferred host infrastructure to capture and lazily start hosts when the test host is consumed. Updates framework abstractions (HostTest, HostFixture) to support both legacy and managed startup paths for backward compatibility during this minor release. Refactors ApplicationHostFactory and WebApplicationTestFactory to route managed fixture requests through the deferred path. Marks BlockingManagedApplicationFixture and BlockingManagedWebApplicationFixture as obsolete. Updates bootstrap sample applications to demonstrate all startup patterns.
Adds comprehensive regression test coverage for the new managed startup patterns across Generic Host and ASP.NET Core scenarios. Includes new functional tests validating entrypoint-owned startup for classic, minimal, Bootstrapper, worker, and modern entry points. Verifies that explicit fixture selection (managed vs blocking) produces the expected startup behavior. Updates existing tests to confirm backward compatibility of legacy factory paths.
Updates DocFX namespace pages and type-level API documentation to reflect the new managed application and web application fixtures. Clarifies the distinction between the new managed startup path (where the application entry point owns host initialization) and the legacy factory/blocking paths (which preserve startup behavior for this minor release). Adds usage guidance and deprecation notices to the API documentation.
Updates NuGet package release notes and README documentation for Codebelt.Extensions.Xunit.Hosting and Codebelt.Extensions.Xunit.Hosting.AspNetCore packages. Adds 'Unreleased' section highlighting the new managed fixtures as the primary feature. Documents the compatibility split: ManagedApplicationFixture and ManagedWebApplicationFixture enable applications where Main owns startup configuration; legacy factory and blocking fixture APIs preserve existing behavior for backward compatibility.
Updates CHANGELOG.md with 11.2.0 release entry documenting the introduction of entrypoint-owned managed fixtures as an opt-in startup path. Highlights backward compatibility split: new ManagedApplicationFixture<TEntryPoint> and ManagedWebApplicationFixture<TEntryPoint> allow applications where the entry point manages host initialization; existing factory and blocking fixture APIs remain unchanged for this minor release. Notes deprecation of BlockingManagedApplicationFixture and BlockingManagedWebApplicationFixture in favor of managed fixtures.
@gimlichael gimlichael self-assigned this Aug 3, 2026
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds opt-in managed fixtures that defer host startup to the application entry point while retaining obsolete blocking fixtures for compatibility.

  • Adds ManagedApplicationFixture<TEntryPoint> and ManagedWebApplicationFixture<TEntryPoint>.
  • Introduces deferred host creation and entry-point resolution infrastructure.
  • Updates application fixtures, tests, examples, documentation, and release notes for the new lifecycle.
  • Corrects the managed-fixture examples to derive from the appropriate test base classes and initialize their fixtures through the base constructors.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Codebelt.Extensions.Xunit.Hosting/ManagedApplicationFixture.cs Adds the opt-in application fixture that configures and exposes an entry-point-owned deferred host.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebApplicationFixture.cs Adds the ASP.NET Core managed fixture and adapts deferred application startup to expose a TestServer.
src/Codebelt.Extensions.Xunit.Hosting/Internal/DeferredHostFactory.cs Centralizes deferred host creation and application-entry-point resolution.
src/Codebelt.Extensions.Xunit.Hosting/Internal/ProgramHostFactoryResolver.cs Extends entry-point discovery and invocation for the managed startup path.
.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md Documents a supported application fixture example that initializes the fixture through ApplicationTest.
.docfx/api/types/Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md Documents a supported web fixture example that initializes the fixture through WebApplicationTest.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    X[xUnit constructs managed fixture] --> T[Test class passes fixture to base constructor]
    T --> C[ConfigureHost initializes deferred host]
    C --> E[Application entry point owns startup]
    E --> A[Test consumes Host or Server]
    A --> S[Deferred host starts and exposes services or TestServer]
    S --> D[xUnit fixture lifecycle disposes host]
Loading

Reviews (3): Last reviewed commit: "🐛 fix bootstrapper async startup and ca..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.06763% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.27%. Comparing base (4eb8d87) to head (712065c).

Files with missing lines Patch % Lines
...s.Xunit.Hosting.BootstrapperConsole.App/Startup.cs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
+ Coverage   92.25%   94.27%   +2.01%     
==========================================
  Files          82       88       +6     
  Lines        1498     1658     +160     
  Branches      169      180      +11     
==========================================
+ Hits         1382     1563     +181     
+ Misses        102       81      -21     
  Partials       14       14              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

aicia-bot and others added 5 commits August 4, 2026 01:28
Remove CreateEntrypointOwnedHost and ReleaseEntrypoint protected methods from HostFixture and inline their logic directly into ManagedApplicationFixture and ManagedWebApplicationFixture. This simplifies the public API surface of HostFixture by keeping entrypoint-owned host logic scoped to the fixtures that use it. Refactor exception handling in DeferredHostBuilder to remove unnecessary try-catch wrapping.
Add integration test to verify ManagedApplicationFixture correctly initializes through ConfigureHost and starts the application entrypoint. Also add test to verify BootstrapperMinimalConsoleProgram handles cancellation gracefully.
Update ManagedApplicationFixture and ManagedWebApplicationFixture documentation examples to show the proper usage pattern: inherit from ApplicationTest or WebApplicationTest base classes and pass the fixture to the base constructor for automatic fixture initialization via ConfigureHost.
Move catch clause to the same line as the closing brace of the try block for consistent formatting style.
Fix the bootstrapper startup to properly implement async/await patterns and respect application lifetime cancellation signals. This ensures the hosted application can be gracefully shutdown by the framework rather than completing immediately.
@gimlichael
gimlichael merged commit bafa291 into main Aug 4, 2026
24 checks passed
@gimlichael
gimlichael deleted the v11.2.0/startup-fix branch August 4, 2026 14:07
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