test(unit-tests): silence captured stdout in Testing env

The unit-test suite was spending most of its wall clock writing logs.
NUnit captures stdout per test and embeds it in the trx; with HttpLogging
emitting full request/response per controller call, EF Core SQL at
Information level, and ReferenceDataImporter banners running ~500x
(once per factory construction), the trx grew to 3.2 GB and the NUnit
result-XML serializer OOMed in StringBuilder.ToString() — which the
runner reported as one mysteriously failed test, masking a real
date-dependent failure underneath.

Three sources silenced under environment "Testing":
- appsettings.Testing.json drops Default + Microsoft.AspNetCore +
  HttpLoggingMiddleware + EntityFrameworkCore to Warning.
- Program.cs skips app.UseHttpLogging() entirely (avoids the
  middleware overhead, not just the log emission).
- ReferenceDataImporter takes optional TextWriters; the test factory
  passes TextWriter.Null. Per-importer helpers become instance methods
  so they can use the injected writer.

Result on a fresh run with ParallelScope.Fixtures already in place:
- Test duration: 1m46s -> 59s
- Wall clock: 2m23s -> 1m00s
- trx size: 3.2 GB -> 1.7 MB

The previously-masked date-dependent failure (PackControllerFullCatalog
.Info_returns_full_35_pack_catalog_from_production_seed asserting 35
active packs as of 2026-05-23 against a live clock) is now visible and
can be addressed separately.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-01 00:13:42 -04:00
parent d093d872ae
commit 7914bab84e
4 changed files with 58 additions and 25 deletions

View File

@@ -151,7 +151,13 @@ public class Program
}
}
app.UseHttpLogging();
// HttpLogging captures full request/response per call. In Testing it pipes ~3 GB of
// stdout into NUnit's per-test result capture across the suite, which OOMs the trx
// serializer. Production keeps it on.
if (!app.Environment.IsEnvironment("Testing"))
{
app.UseHttpLogging();
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Warning",
"Microsoft.EntityFrameworkCore": "Warning"
}
}
}