Skip to content

Migrate test infrastructure from WebHostBuilder to#9468

Open
michaelstaib wants to merge 7 commits intomainfrom
mst/webhostbuilder-migration
Open

Migrate test infrastructure from WebHostBuilder to#9468
michaelstaib wants to merge 7 commits intomainfrom
mst/webhostbuilder-migration

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 12:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the test hosting infrastructure from WebHostBuilder/IWebHost patterns to WebApplication (minimal hosting) across multiple test projects, and updates several HTTP streaming tests/snapshots to use GraphQLHttpResponse.

Changes:

  • Replace WebHostBuilder/TestServer setup with WebApplication.CreateSlimBuilder() + UseTestServer() / UseUrls() in multiple test helpers/sessions.
  • Update StrawberryShake integration tests to dispose the new WebApplication hosts (await using) and adjust client helper signatures.
  • Update GraphQL-over-HTTP/defer streaming tests to wrap responses with GraphQLHttpResponse and enhance snapshot formatting for jsonl/SSE streaming payloads.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/UploadScalarTest.cs Switch server lifetime handling to WebApplication and async disposal.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/UnsignedTypesTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsOnReviewSubNoStoreTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsOnReviewSubGraphQLSSETest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsOnReviewSubCompletionTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroWithFragmentIncludeAndSkipDirectiveTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTraitsTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsNoStoreTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferredTest.cs Update commented template snippet to new server creation style.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetFriendsDeferInListTest.cs Update commented template snippet to new server creation style.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/LocalTypesTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/AnyScalarDefaultSerializationTest.cs Use async disposal for server created via updated helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/resources/TestTemplate.txt Update generated test template to new hosting pattern.
src/StrawberryShake/Client/test/Transport.WebSocket.Tests/TestHelper/TestServerHelper.cs Re-implement server creation using WebApplication + Kestrel/URLs.
src/StrawberryShake/Client/test/Transport.WebSocket.Tests/IntegrationTests.cs Dispose updated WebApplication server via await using.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/TestServerSession.cs Replace WebHostBuilder/TestServer lifecycle with WebApplication-based lifecycle.
src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs Improve activity parent correlation using span-id lookup.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/TestServerSession.cs Replace WebHostBuilder/TestServer lifecycle with WebApplication-based lifecycle.
src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs Improve activity parent correlation using span-id lookup.
src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorVariablesTests.cs Switch to WebApplication+UseTestServer() for in-memory sorting test server.
src/HotChocolate/Caching/test/Caching.Tests/TestServerFactory.cs Switch test server factory to WebApplication instances and GetTestServer().
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs Use GraphQLHttpResponse to read SSE result streams; adjust timeouts/assertions.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/DeferOverHttpTests.cs Wrap streaming responses in GraphQLHttpResponse and snapshot the patched result.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/TestServerFactory.cs Switch shared test server factory to WebApplication instances and GetTestServer().
src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/Subscriptions/GraphQLOverWebSocket/SubscriptionTestBase.cs Increase retry/timeout window for flaky subscription tests.
src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationPolicyProviderTests.cs Implement fallback policy method to return null instead of throwing.
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/TestServerSession.cs Replace WebHostBuilder/TestServer lifecycle with WebApplication-based lifecycle.
src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/FusionIntegrationTests.cs Switch gateway/subgraph test servers to WebApplication + UseTestServer().
src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/CoreIntegrationTests.cs Switch MCP test servers to WebApplication + UseTestServer().
src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/GraphQLHttpResponseFormatter.cs Add formatting support for SSE/jsonl result streams by patching incremental payloads.
src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/ExecutionResultSnapshotValueFormatter.cs Add legacy incremental patch handling when path is present without id.
Comments suppressed due to low confidence (1)

src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/UploadScalarTest.cs:219

  • CreateClient takes a WebApplication host parameter but never uses it. Since callers already keep host alive in the test scope, consider removing this parameter (and updating call sites) to avoid confusion and keep the helper focused on what it actually needs (the port/base address).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants