title: Override Startup in WebApplicationFactory does not map endpoints
body: <p>I have configured an xUnit project to test an Identity Server implementation. I have created a <code>TestStartup</code> class which inherits <code>Startup</code> and overrides my Identity Server implementation for testing purposes. The problem  is when I call my <code>TestStartup</code> using my custom <code>WebApplicationFactory</code>, my endpoints are not mapped. If I call <code>Startup</code> from my custom <code>WebApplicationFactory</code>, my endpoints are mapped.</p>
  
  <p>Startup.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>protected readonly IConfiguration _configuration;
  protected readonly IWebHostEnvironment _webHostEnvironment;
  
  public Startup(IConfiguration configuration, IWebHostEnvironment environment)
  {
      _configuration = configuration;
      _webHostEnvironment = environment;
  }
  
  public virtual void ConfigureServices(IServiceCollection services)
  {
      ///code goes here
      ConfigureIdentityServices(services);            
  }
  
  /// &lt;summary&gt;
  /// Split into its own method so we can override for testing
  /// &lt;/summary&gt;
  /// &lt;param name="services"&gt;&lt;/param&gt;
  public virtual void ConfigureIdentityServices(IServiceCollection services)
  {
     ///code goes here
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
  
      app.UseIdentityServer();
      app.UseRouting();
  
      //app.UseAuthorization();
  
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllers();
      });
  }
  </code></pre>
  
  <p>TestStartup.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>public TestStartup(IConfiguration configuration, IWebHostEnvironment environment) : base(configuration, environment)
  {
  
  }
  
  public override void ConfigureServices(IServiceCollection services)
  {
      base.ConfigureServices(services);
  }
  
  /// &lt;summary&gt;
  /// In memory identity database implementation for testing
  /// &lt;/summary&gt;
  /// &lt;param name="services"&gt;&lt;/param&gt;
  public override void ConfigureIdentityServices(IServiceCollection services)
  {
      //test implementation
  }
  
  public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
      base.Configure(app, env);          
  }
  </code></pre>
  
  <p>Custom WebApplicationFactory</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ApplicationFactory&lt;TStartup&gt; : WebApplicationFactory&lt;TStartup&gt; where TStartup : class
  {
      protected override IWebHostBuilder CreateWebHostBuilder()
      {
          return WebHost.CreateDefaultBuilder(null).UseEnvironment("Development")
                      .UseStartup&lt;TStartup&gt;();
      }
  }
  </code></pre>
  
  <p>Controller Test Class</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class UserControllerTests : IClassFixture&lt;ApplicationFactory&lt;Startup&gt;&gt;
  {
      private readonly ApplicationFactory&lt;Startup&gt; _factory;
  
      public UserControllerTests(ApplicationFactory&lt;Startup&gt; factory)
      {
          _factory = factory;
      }
  
      [Fact]
      public async Task Get_Users()
      {
          var client = _factory.CreateClient();
  
          var result = await client.GetAsync("/user/users");
          result.StatusCode.Should().Be(HttpStatusCode.OK);
      }
  
  }
  </code></pre>
  
  <p>When I run my controller test, if inject <code>TestStartup</code> instead of <code>Startup</code>, I don't get any endpoints returned from the endpoint routing, even though I call the <code>base.Configure(app,env)</code> method from my <code>TestStartup</code> class.</p>