Open andrewjsaid opened 3 months ago
@andrewjsaid Thanks for filing this issue! The default behavior that you see here is a result of logic that is included in the WebApplicationBuilder's implemenetation. As you observed, it's gated behind an IsDevelopment
check so modifying the environment name under test breaks this default behavior.
We're planning on doing a round of improvements for the integration testing area soon so I'm marking this as something we could potentially look into as part of the workstream.
For now, I'm sticking this in the backlog given there is a feasible workaround for the issue.
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
In the context of
WebApplicationFactory
which is intended for testing, the service provider optionsValidateScopes
andValidateOnBuild
are not specifically set, and instead rely on the environment to be Development.API Code: When run in dev mode this throws exception due to invalid DI setup.
Test Code: E2E tests pass
Describe the solution you'd like
The options
ValidateScopes
andValidateOnBuild
should be true by default when usingWebApplicationFactory<TEntryPoint>
which is designed for testing.Additional context
This can easily be done manually via the following code. It's just unexpected that this isn't the default.