Skip to content

Reduce tests verbosity in cibuild #1430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/DapperTests/IntegrationTests/DapperTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ private WebApplicationFactory<TodoItem> CreateFactory()
{
if (_testOutputHelper != null)
{
#if !DEBUG
// Reduce logging output when running tests in ci-build.
loggingBuilder.ClearProviders();
#endif
loggingBuilder.Services.AddSingleton<ILoggerProvider>(_ => new XUnitLoggerProvider(_testOutputHelper, "DapperExample."));
}
});
Expand Down
8 changes: 4 additions & 4 deletions test/TestBuildingBlocks/IntegrationTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private WebApplicationFactory<TStartup> 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<TStartup> factoryWithConfiguredContentRoot =
factory.WithWebHostBuilder(builder => builder.UseSolutionRelativeContentRoot($"test/{nameof(TestBuildingBlocks)}"));

Expand Down Expand Up @@ -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();
Expand Down