Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fc5a0b7

Browse files
Reduce logging output when running tests in ci-build (#1430)
1 parent ee0b942 commit fc5a0b7

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

‎.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ jobs:
127127
run: |
128128
dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
129129
- name: Test
130+
env:
131+
# Override log levels, to reduce logging output when running tests in ci-build.
132+
Logging__LogLevel__Microsoft.Hosting.Lifetime: 'None'
133+
Logging__LogLevel__Microsoft.AspNetCore.Hosting.Diagnostics: 'None'
134+
Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host: 'None'
135+
Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command: 'None'
136+
Logging__LogLevel__JsonApiDotNetCore: 'None'
130137
run: |
131138
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
132139
- name: Upload coverage to codecov.io

‎test/DapperTests/IntegrationTests/DapperTestContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ private WebApplicationFactory<TodoItem> CreateFactory()
6969
{
7070
if (_testOutputHelper != null)
7171
{
72+
#if !DEBUG
73+
// Reduce logging output when running tests in ci-build.
74+
loggingBuilder.ClearProviders();
75+
#endif
7276
loggingBuilder.Services.AddSingleton<ILoggerProvider>(_ => new XUnitLoggerProvider(_testOutputHelper, "DapperExample."));
7377
}
7478
});

‎test/TestBuildingBlocks/IntegrationTestContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ private WebApplicationFactory<TStartup> CreateFactory()
8383
});
8484
});
8585

86-
// We have placed an appsettings.json in the TestBuildingBlock project folder and set the content root to there. Note that controllers
87-
// are not discovered in the content root but are registered manually using IntegrationTestContext.UseController.
86+
// We have placed an appsettings.json in the TestBuildingBlocks project directory and set the content root to there. Note that
87+
// controllers are not discovered in the content root, but are registered manually using IntegrationTestContext.UseController.
8888
WebApplicationFactory<TStartup> factoryWithConfiguredContentRoot =
8989
factory.WithWebHostBuilder(builder => builder.UseSolutionRelativeContentRoot($"test/{nameof(TestBuildingBlocks)}"));
9090

@@ -161,8 +161,8 @@ protected override IHostBuilder CreateHostBuilder()
161161
.CreateDefaultBuilder(null)
162162
.ConfigureAppConfiguration(builder =>
163163
{
164-
// For tests asserting on log output, we discard the logging settings from appsettings.json.
165-
// But using appsettings.json for all other tests makes it easy to quickly toggle when debugging.
164+
// For tests asserting on log output, we discard the log levels from appsettings.json and environment variables.
165+
// But using appsettings.json for all other tests makes it easy to quickly toggle when debugging tests.
166166
if (_loggingConfiguration != null)
167167
{
168168
builder.Sources.Clear();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /