diff --git a/RpgRoller.Tests/HostingCoverageTests.cs b/RpgRoller.Tests/HostingCoverageTests.cs index 32d083d..8af87a4 100644 --- a/RpgRoller.Tests/HostingCoverageTests.cs +++ b/RpgRoller.Tests/HostingCoverageTests.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using RpgRoller.Data; using RpgRoller.Hosting; @@ -272,6 +273,9 @@ public sealed class HostingCoverageTests ContentRootPath = Path.GetTempPath(), EnvironmentName = Environments.Development }); + builder.Logging.AddFilter("Microsoft.AspNetCore", LogLevel.Warning); + builder.Logging.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning); + builder.Logging.AddFilter("Microsoft.Hosting", LogLevel.Warning); builder.Configuration.AddInMemoryCollection(new Dictionary { ["ConnectionStrings:RpgRoller"] = $"Data Source={copiedDbPath}" diff --git a/RpgRoller.Tests/Support/ApiTestBase.cs b/RpgRoller.Tests/Support/ApiTestBase.cs index 742ee98..7a5a6be 100644 --- a/RpgRoller.Tests/Support/ApiTestBase.cs +++ b/RpgRoller.Tests/Support/ApiTestBase.cs @@ -1,6 +1,8 @@ +using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Logging; using RpgRoller.Data; using RpgRoller.Hosting; @@ -31,20 +33,29 @@ public abstract class ApiTestBase : IClassFixture protected WebApplicationFactory CreateFactory(params int[] rollValues) { - return m_BaseFactory.WithWebHostBuilder(builder => builder.ConfigureServices(services => + return m_BaseFactory.WithWebHostBuilder(builder => { - services.RemoveAll(); - services.AddSingleton(new FixedDiceRoller(rollValues)); + builder.ConfigureLogging(logging => + { + logging.AddFilter("Microsoft.AspNetCore", LogLevel.Warning); + logging.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning); + logging.AddFilter("Microsoft.Hosting", LogLevel.Warning); + }); + builder.ConfigureServices(services => + { + services.RemoveAll(); + services.AddSingleton(new FixedDiceRoller(rollValues)); - services.RemoveAll>(); - services.RemoveAll>(); - services.RemoveAll(); - services.RemoveAll(); + services.RemoveAll>(); + services.RemoveAll>(); + services.RemoveAll(); + services.RemoveAll(); - var dbPath = Path.Combine(Path.GetTempPath(), $"rpgroller-tests-{Guid.NewGuid():N}.db"); - services.AddSingleton(new SqliteDatabaseFile(dbPath)); - services.AddDbContextFactory(options => options.UseSqlite($"Data Source={dbPath}")); - })); + var dbPath = Path.Combine(Path.GetTempPath(), $"rpgroller-tests-{Guid.NewGuid():N}.db"); + services.AddSingleton(new SqliteDatabaseFile(dbPath)); + services.AddDbContextFactory(options => options.UseSqlite($"Data Source={dbPath}")); + }); + }); } protected static async Task RegisterAsync(HttpClient client, string username, string password, string displayName) diff --git a/RpgRoller/appsettings.json b/RpgRoller/appsettings.json index 69fd2a8..95aaea9 100644 --- a/RpgRoller/appsettings.json +++ b/RpgRoller/appsettings.json @@ -5,7 +5,9 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Warning", + "Microsoft.Hosting": "Warning" } }, "AllowedHosts": "*" diff --git a/scripts/ci-local.ps1 b/scripts/ci-local.ps1 index 4ee307f..1373177 100644 --- a/scripts/ci-local.ps1 +++ b/scripts/ci-local.ps1 @@ -27,13 +27,13 @@ Push-Location $repoRoot try { if (-not $SkipDotnetRestore) { Invoke-Step -Name "Restore .NET solution" -Action { - dotnet restore RpgRoller.sln + dotnet restore RpgRoller.sln --verbosity minimal } } if (-not $SkipBuild) { Invoke-Step -Name "Build .NET solution (warnings as errors)" -Action { - dotnet build RpgRoller.sln --no-restore -warnaserror + dotnet build RpgRoller.sln --no-restore -warnaserror --verbosity minimal } } @@ -47,10 +47,10 @@ try { Invoke-Step -Name "Run tests" -Action { if ($SkipBuild) { - dotnet test RpgRoller.Tests/RpgRoller.Tests.csproj --verbosity normal --collect:"XPlat Code Coverage" --settings RpgRoller.Tests/coverlet.runsettings + dotnet test RpgRoller.Tests/RpgRoller.Tests.csproj --verbosity minimal --collect:"XPlat Code Coverage" --settings RpgRoller.Tests/coverlet.runsettings } else { - dotnet test RpgRoller.Tests/RpgRoller.Tests.csproj --no-build --verbosity normal --collect:"XPlat Code Coverage" --settings RpgRoller.Tests/coverlet.runsettings + dotnet test RpgRoller.Tests/RpgRoller.Tests.csproj --no-build --verbosity minimal --collect:"XPlat Code Coverage" --settings RpgRoller.Tests/coverlet.runsettings } }