diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26028cba5a..eb3aab63b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,6 +127,13 @@ jobs: run: | dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX - name: Test + env: + # Override log levels, to reduce logging output when running tests in ci-build. + Logging__LogLevel__Microsoft.Hosting.Lifetime: 'None' + Logging__LogLevel__Microsoft.AspNetCore.Hosting.Diagnostics: 'None' + Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host: 'None' + Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command: 'None' + Logging__LogLevel__JsonApiDotNetCore: 'None' run: | dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true" - name: Upload coverage to codecov.io diff --git a/test/DapperTests/IntegrationTests/DapperTestContext.cs b/test/DapperTests/IntegrationTests/DapperTestContext.cs index 6bbcca6777..233162e2e8 100644 --- a/test/DapperTests/IntegrationTests/DapperTestContext.cs +++ b/test/DapperTests/IntegrationTests/DapperTestContext.cs @@ -69,6 +69,10 @@ private WebApplicationFactory CreateFactory() { if (_testOutputHelper != null) { +#if !DEBUG + // Reduce logging output when running tests in ci-build. + loggingBuilder.ClearProviders(); +#endif loggingBuilder.Services.AddSingleton(_ => new XUnitLoggerProvider(_testOutputHelper, "DapperExample.")); } }); diff --git a/test/TestBuildingBlocks/IntegrationTestContext.cs b/test/TestBuildingBlocks/IntegrationTestContext.cs index dc186b474b..83f00667b2 100644 --- a/test/TestBuildingBlocks/IntegrationTestContext.cs +++ b/test/TestBuildingBlocks/IntegrationTestContext.cs @@ -83,8 +83,8 @@ private WebApplicationFactory CreateFactory() }); }); - // We have placed an appsettings.json in the TestBuildingBlock project folder and set the content root to there. Note that controllers - // are not discovered in the content root but are registered manually using IntegrationTestContext.UseController. + // We have placed an appsettings.json in the TestBuildingBlocks project directory and set the content root to there. Note that + // controllers are not discovered in the content root, but are registered manually using IntegrationTestContext.UseController. WebApplicationFactory factoryWithConfiguredContentRoot = factory.WithWebHostBuilder(builder => builder.UseSolutionRelativeContentRoot($"test/{nameof(TestBuildingBlocks)}")); @@ -161,8 +161,8 @@ protected override IHostBuilder CreateHostBuilder() .CreateDefaultBuilder(null) .ConfigureAppConfiguration(builder => { - // For tests asserting on log output, we discard the logging settings from appsettings.json. - // But using appsettings.json for all other tests makes it easy to quickly toggle when debugging. + // For tests asserting on log output, we discard the log levels from appsettings.json and environment variables. + // But using appsettings.json for all other tests makes it easy to quickly toggle when debugging tests. if (_loggingConfiguration != null) { builder.Sources.Clear();