You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Steps to reproduce (preferably a link to a GitHub repo with a repro project):
Create subclass of WebApplicationFactory
Override WebApplicationFactory.ConfigureWebHost and configure testing specific services
Debug tests with breakpoints in TStartup.ConfigureServices
Description of the problem:
I'm using a custom subclass of WebApplicationFactory in order to wire up testing services (namely, a allow any authentication scheme and custom user service) however, after the testing services are configured the base startup classes configure method is called, effectively blowing away my test services
and using real authentication and a real user service.
Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:
Microsoft.AspNetCore.App 2.1.2
It seems intuitive to me that the startup classes configuration should be executed first, and the custom web application's factory then has the option to override the applications production configuration, but if I'm using this incorrectly, then I'd like some guidance on how to do this.
I tried using an testing specific startup class, but then Mvc couldn't find my controllers and all routes returned 404.
right now I have an ugly hack where the integration test sets the environment to "Testing" and the startup class ConfigureServices method returns immediately if environment is "Testing"
Would really like to avoid adding any testing code to my main application project.