© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
Dr_Cox1911

❔ WebApplicationFactory and Minimal-APIs

I've got problems with my integration tests and minimal apis.
My app has a worker services that start right up when the actual api is starting.

I have a custom
WebApplicationFactory
WebApplicationFactory
that will swap out the Database with one thats started by
Testcontainers
Testcontainers
.

My problem though: With the top level statements and the builder that minimal apis use it looks like the app is completely started and in parallel the builder of the
WebApplicationFactory
WebApplicationFactory
runs. My worker service crashes though, as it get's started before my custom
WebApplicationFactory
WebApplicationFactory
finishes with changing out the db.

I've never faced these issues in the traditional
Startup
Startup
era, so can I use
WebApplicationFactory
WebApplicationFactory
properly with top level statements?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Eagerly compile minimal apis
C#CC# / help
2y ago
Unit Testing in Minimal Apis
C#CC# / help
11mo ago
✅ Generic DI in minimal APIs
C#CC# / help
3y ago
❔ WebApplicationFactory and integration tests
C#CC# / help
3y ago