CreateHostBuilder / configuration to a specific environement
In the "Set the environment" section, the doc refers to setting the value of env variables w/o showing how to do it. But the goal can be achieved that way. I suggest you add this code snippet:
protected override IHostBuilder CreateHostBuilder() =>
base.CreateHostBuilder().ConfigureWebHost(x => x.UseEnvironment("integration"));
The derived WebApplicationFactory will therefore create the SUT with a specific environment, which allows for example to use a specific appsetting.ENV.json defined in the API project (as you'd have an appsetting.Development.json, etc...)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 77889d43-fedb-f8b4-8fea-379ec946555c
- Version Independent ID: f499b131-8b14-7e10-1728-543fdd5a5656
- Content: Integration tests in ASP.NET Core
- Content Source: aspnetcore/test/integration-tests.md
- Product: aspnet-core
- Technology: aspnetcore-test
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
@javiercn can I add the following tip?
@Rick-Anderson sounds fine with me.
/cc: @captainsafia
Is anyone working on this issue? Otherwise, I'd like to try it out, I'm new to open-source.
Is anyone working on this issue? Otherwise, I'd like to try it out, I'm new to open-source.
@kianiehsan66 help would be appreciated. The first step would be updating https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample to show how it works.
Looks like it's there now.