diff --git a/eng/helix/content/runtests.cmd b/eng/helix/content/runtests.cmd index 3aab373c69c9..a3c6de9c0a45 100644 --- a/eng/helix/content/runtests.cmd +++ b/eng/helix/content/runtests.cmd @@ -18,6 +18,9 @@ set InstallPlaywright=%$installPlaywright% set PLAYWRIGHT_BROWSERS_PATH=%CD%\ms-playwright set PLAYWRIGHT_DRIVER_PATH=%CD%\.playwright\win-x64\native\playwright.cmd +REM Avoid https://github.com/dotnet/aspnetcore/issues/41937 in current session. +set ASPNETCORE_ENVIRONMENT= + set "PATH=%HELIX_WORKITEM_ROOT%;%PATH%;%HELIX_WORKITEM_ROOT%\node\bin" echo Set path to: "%PATH%" echo. diff --git a/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs b/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs index d275e88e93c5..f84425f734cd 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Xunit; +using Xunit.Abstractions; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { @@ -18,13 +19,16 @@ public class SimpleWithWebApplicationBuilderTests : IClassFixture _fixture; - public SimpleWithWebApplicationBuilderTests(MvcTestFixture fixture) + public SimpleWithWebApplicationBuilderTests(MvcTestFixture fixture, + ITestOutputHelper helper) { _fixture = fixture; Client = _fixture.CreateDefaultClient(); + Helper = helper; } public HttpClient Client { get; } + public ITestOutputHelper Helper { get; } [Fact] public async Task HelloWorld() @@ -131,7 +135,7 @@ public async Task MvcControllerActionWorks() Assert.Equal("Hello human", content); } - [Fact(Skip = "Failing on Windows environments: https://github.com/dotnet/aspnetcore/issues/41937")] + [Fact] public async Task DefaultEnvironment_Is_Development() { // Arrange @@ -142,6 +146,14 @@ public async Task DefaultEnvironment_Is_Development() var content = await client.GetStringAsync("http://localhost/environment"); // Assert + if (!string.Equals(expected, content)) + { + // Get more information when this test is going to fail. + var configContent = await client.GetStringAsync("http://localhost/config"); + + Helper.WriteLine($"Configuration debug view: '{configContent}'"); + } + Assert.Equal(expected, content); } diff --git a/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs b/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs index ea06879f0b72..80e9743ece4d 100644 --- a/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs +++ b/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs @@ -34,6 +34,10 @@ app.MapGet("/problem", () => Results.Problem("Some problem")); app.MapGet("/environment", (IHostEnvironment environment) => environment.EnvironmentName); +app.MapGet("/config", (IConfiguration config, HttpContext context) => { + return context.Response.WriteAsync(((IConfigurationRoot)config).GetDebugView()); +}); + app.MapGet("/webroot", (IWebHostEnvironment environment) => environment.WebRootPath); app.MapGet("/greeting", (IConfiguration config) => config["Greeting"]);