Skip to content

Replace WebApplicationFactory in tests with WebApplicationBuilder#2014

Merged
bkoelman merged 1 commit into
masterfrom
replace-web-application-factory
Jul 6, 2026
Merged

Replace WebApplicationFactory in tests with WebApplicationBuilder#2014
bkoelman merged 1 commit into
masterfrom
replace-web-application-factory

Conversation

@bkoelman

@bkoelman bkoelman commented May 26, 2026

Copy link
Copy Markdown
Member

All integration tests currently use WebApplicationFactory, which is designed to run tests against an existing app. It sets the content root, solution root and startup project, enables overriding service container entries and more.

But nowadays, most integration tests no longer reference an actual app; they run entirely in a test project. We've been fighting the defaults of WebApplicationFactory to enable that, but keep running into limitations. For example, constraints apply to where the Startup class can be defined. For integration tests that don't reference an actual app, it makes more sense to use the underlying TestServer directly against a freshly built app using WebApplicationBuilder.

This PR replaces WebApplicationFactory usage with the direct approach for all integration tests that don't reference an actual app. It also optimizes database throttling and timeouts to better handle PostgreSQL's maximum connection limits during test runs. The FactoryBridge temporary type was introduced to avoid adapting all existing tests, so this PR focuses only on the test infrastructure.

QUALITY CHECKLIST

@bkoelman
bkoelman force-pushed the replace-web-application-factory branch 2 times, most recently from 9b4fde2 to c7f5032 Compare May 26, 2026 01:38
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.96%. Comparing base (dbda7be) to head (c9e6cf0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2014      +/-   ##
==========================================
- Coverage   92.12%   91.96%   -0.16%     
==========================================
  Files         438      438              
  Lines       15044    15044              
  Branches     2488     2488              
==========================================
- Hits        13859    13835      -24     
- Misses        731      755      +24     
  Partials      454      454              

☔ 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.

@bkoelman
bkoelman force-pushed the replace-web-application-factory branch 4 times, most recently from 030965e to 0b87b53 Compare July 5, 2026 08:27
@bkoelman
bkoelman force-pushed the replace-web-application-factory branch from caeb73c to c9e6cf0 Compare July 6, 2026 06:41
@bkoelman
bkoelman marked this pull request as ready for review July 6, 2026 07:02
@bkoelman
bkoelman merged commit 538cbf9 into master Jul 6, 2026
15 checks passed
@bkoelman
bkoelman deleted the replace-web-application-factory branch July 6, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant