title: Net Core Integration Test: Run Startup.cs and Configuration from other Program
body: <p>We are creating an Integration Unit test (Xunit), which is calling the Real Application Startup.cs.</p>
  
  <p>For some reason, Real project can read Configuration file/property correctly, however running it from the Integration test, it cannot read it. Its not placing anything into Configuration (conf) variable below. How would I resolve this?
  The reason is its not picking up is its not reading the internal dependency injection new from Net Core 2.2 which reads Configuration file. Trying to use .CreateDefaultBuilder Now.</p>
  
  <p><strong>IntegrationTest1.cs</strong></p>
  
  <pre><code>        TestServer _server = new TestServer(new WebHostBuilder() .UseContentRoot("C:\\RealProject\\RealProject.WebAPI")
              .UseEnvironment("Development")
              .UseConfiguration(new ConfigurationBuilder()
              .SetBasePath("C:\\RealProject\\RealProject.WebAPI")
                  .AddJsonFile("appsettings.json")
                  .Build())
                  .UseStartup&lt;Startup&gt;()
              .UseStartup&lt;Startup&gt;());
  </code></pre>
  
  <p><strong>Real Project Startup.cs</strong></p>
  
  <pre><code>    public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
      {
          Configuration = configuration;
          HostingEnvironment = hostingEnvironment;
      }
  
      public IHostingEnvironment HostingEnvironment { get; }
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public IServiceProvider ConfigureServices(IServiceCollection services)
      {
  
          var conf = Configuration;
          IConfiguration appConf = conf.GetSection("ConnectionStrings");
          var connstring = appConf.GetValue&lt;string&gt;("DatabaseConnection");
  
          services.AddDbContext&lt;DbContext&gt;(a =&gt; a.UseSqlServer(connstring));
  </code></pre>
  
  <p>Appsettings.Json</p>
  
  <pre><code>{
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "ConnectionStrings": {
      "DatabaseConnection": "Data Source=.;Initial Catalog=ApplicationDatabase;Integrated Security=True"
    }
  }
  </code></pre>