Guides & specifications
Integration-Test Tier Rework Plan (RemediationBacklog #14)
As of: 2026-10-28.
Status: complete (all phases landed; the integration tier collects coverage through dotnet-coverage).
Speaker analytics cross-service reads are the only deferred item.
- Phase 0, done. The
MMCA.Common.APImiddleware unit tests are consolidated intoMMCA.Common.API.Testsin MMCA.Common (Common owns the full exception-handler coverage); ADC carries noWebAPI.Testscopy. - Phase 1 (Identity), done.
Tests/Integration/MMCA.ADC.Identity.IntegrationTests:IdentityIntegrationTestFixturederives from the sharedSqlServerIntegrationTestFixtureBase<Program>inMMCA.Common.Testing(boots the host viaWebApplicationFactory<Program>, overrides config via process env vars set before the host starts, real SQL DB viaADC_TEST_SQL_BASE/LocalDB, schema applied byDatabaseInitStrategy=Migrate, Respawn reset, drop-on-dispose). The first re-homed classes areAnonymousAuthTests(8 tests) andAttendeeClaimsTests(4). The tier cannot run in the headless dev environment (no reachable SQL Server); it runs in theintegration-testsjob ofdeploy.ymlagainst a pinned SQL Server container (mssql/server:2022-CU27-ubuntu-22.04). Run viaMMCA.ADC.Integration.slnf. - Phase 2 (Conference), done.
Tests/Integration/MMCA.ADC.Conference.IntegrationTests: the WAF re-points theAddForwardedJwtBearerBearer scheme at the in-memory test key (PostConfigure<JwtBearerOptions>callingJwtTokenGenerator.ConfigureInProcessTokenValidation) and fakes the Engagement gRPCIBookmarkCountService(FakeBookmarkCountService). The host needs no test-specific guard:Conference.Service/Program.csends withapp.RunAsync(), and its output-cache warm-up runs as an ADR-025IWarmupTask(SelfHttpOutputCacheWarmupTask) that short-circuits in theTestingenvironment. Re-homedAnonymousConferenceReadTests(41 tests: anonymous reads + organizer-authenticated writes, so it exercises the JWT override). InMMCA.ADC.Integration.slnf(same CI job). - Phase 3 (Engagement), done.
Tests/Integration/MMCA.ADC.Engagement.IntegrationTests: same WAF shape as Conference (JWT in-process override; Engagement also usesapp.RunAsync()), with the Conference gRPCISessionBookmarkValidationServicefaked (FakeSessionBookmarkValidationService, validates every session except a sentinel id).AttendeeBookmarkTests(10 tests) re-homed and adapted to Engagement-only: bookmark CRUD, empty list, delete-then-get, duplicate -> 409, ineligible-session -> 400/404, and theOwnerOrAdminFilterownership matrix (attendee-self / organizer-any / other-attendee -> 403). InMMCA.ADC.Integration.slnf. - Breadth fan-out, done. The single-service tests are re-homed onto the per-service fixtures: Conference: Organizer Event/Session/Room/Question/Category CRUD + lifecycle + edge-cases, Associations, Attendee Q&A, Speaker management/update-auth; Identity +4 files (21 tests): Auth edge-cases, Attendee auth, Attendee profile (
/UserClaims), Organizer user management. Access-denied authz matrices split + re-homed (55 tests, the #11 authz-gate coverage):Anonymous-> Identity 5 / Conference 21 / Engagement 4;Attendee-> Conference 24 / Identity 1. The tier has since grown past the re-homed set (ConferenceContract/andData/fidelity tests,OrganizerConcurrencyTests; Engagement check-ins, live polls, points and session questions; Identity compliance, rate limiting and contract tests). - Notification tier.
Tests/Integration/MMCA.ADC.Notification.IntegrationTestsfollows the same shape (NotificationIntegrationTestFixture; JWT in-process override that keeps the?access_token=hub fallback; the Identity gRPCIAttendeeQueryServicefaked) and is the fourth project inMMCA.ADC.Integration.slnf. - Current size. Declared
[Fact]methods per project: Identity 88 (21 files), Conference 250 (33 files), Engagement 91 (12 files), Notification 20 (3 files), so 449 acrossMMCA.ADC.Integration.slnf; the contract-test classes also inherit facts from the sharedMMCA.Common.Testingconformance bases. The CI step enforces--minimum-expected-tests 450against a measured run total of 462. - Phase 5, done: the integration tier is a required PR check with coverage. The
integration-testsjob lives indeploy.ymland runs onpull_requestonly:mainis branch-protected (PR plus required checks, strict up-to-date), so the PR run tests the exact tree that merges, and the job is not indeploy.needs. A docs-only diff skips the SQL container and the test step while the job still posts its required status. The test step wrapsdotnet test --solution MMCA.ADC.Integration.slnfindotnet-coverage collect -f coberturaand uploads thecoverage-integrationartifact, which the report-onlycoveragejob merges with the unit tier. - Phase 4 (cross-service flows), done: in-process handler tests plus the broker-transport tier.
The two load-bearing cross-service flows are re-homed as in-process consumer-handler integration
tests on the per-service fixtures (no Docker: they resolve the real
IIntegrationEventHandler<T>from the booted host and assert against the real DB; they run in the SQLintegration-testsjob, same as Phases 1-3):- BR-207 auto-link:
Tests/Integration/MMCA.ADC.Conference.IntegrationTests/CrossService/CrossServiceUserRegisteredTests.csdrives Conference'sUserRegisteredHandler(email-match link, name-only match never links, no-match skip). ComplementsOutboxFidelityTests(Identity tier, which proves the producer enqueues the event): the consumer auto-link is covered too. - Speaker-link round-trip:
Tests/Integration/MMCA.ADC.Identity.IntegrationTests/CrossService/CrossServiceSpeakerLinkTests.csdrives Identity'sSpeakerLinkedToUserHandler/SpeakerUnlinkedFromUserHandler(sets / clearsUser.LinkedSpeakerId). - Both resolve handlers through the
Servicesaccessor thatSqlServerIntegrationTestFixtureBaseexposes. - Broker-transport tier (container-backed).
Tests/Integration/MMCA.ADC.CrossService.IntegrationTests(CrossServiceFixtureover the sharedCrossServiceFixtureBase) boots the Identity, Conference and Engagement REST hosts plus two Notification replicas in one process (extern-aliasProgramaccess) against real Testcontainers SQL Server, RabbitMQ and Redis. It proves the genuine MassTransit broker round-trip (UserRegistered-> auto-link andSpeakerLinked/Unlinkedtransit outbox -> broker -> consumer, not just handler logic), the Conference -> Engagement bookmark-count gRPC read (Engagement on a real Kestrel socket), and the Notification Redis backplane fan-out across replicas (TwoReplicaHubFanOutTests). 11 tests in 5 classes, behind theCrossServiceSmokeTestssmoke gate. It runs incross-service-tests.yml(weeknights at 06:00 UTC plusworkflow_dispatch, with a skip-if-unchanged guard) alongside theServiceBusEmulator.IntegrationTeststransport smoke (2 tests), needs Docker, and is excluded from both slnf filters. The workflow is never indeploy.needs; instead thecross-service-freshnessstep of the deploy'sfreshnessjob fails a deploy when no run proving both jobs completed within 5 days. Speaker analytics cross-service reads remain the only deferred item (low value; revisit if needed).
- BR-207 auto-link:
The original combined MMCA.ADC.IntegrationTests (258 tests / 29 files) and MMCA.ADC.WebAPI.Tests
referenced the deleted single MMCA.ADC.WebAPI host. Their single-service tests are re-homed
(breadth fan-out above) and their headline cross-service flows are re-homed (Phase 4 above); the
combined project folder is deleted, and the per-service projects under Tests/Integration are the
integration tier.
Recommended strategy: two tiers
- Primary: per-service
WebApplicationFactory<Program>: one in-process host per service (Identity / Conference / Engagement), cross-service edges mocked.AddBrokerMessagingshort-circuits to in-process whenMessageBus:Provideris absent, so no broker container is needed. Covers ~80% of the suite (auth gate, CRUD, validation, soft-delete, ownership). - Secondary: real-broker + real-gRPC. Testcontainers RabbitMQ (plus SQL Server and Redis), for
the genuine cross-process flows (BR-207
UserRegistered-> speaker auto-link,SpeakerLinkedToUser/SpeakerUnlinkedFromUserround-trip, Conference -> Engagement bookmark count, Notification backplane fan-out). Token validation stays in-process here too; the published JWKS and OpenID discovery documents are proven separately byJwksDiscoveryTestson the JWKS-enabled Identity fixture. - Aspire
DistributedApplicationTestingBuilderis deferred to the existing Playwright E2E lane (too heavy for the integration tier; overlaps E2E).
Three code facts that shape the rework (verified)
- Every service host is WAF-compatible: Identity, Conference, Engagement and Notification all end
with
app.RunAsync(). Self-HTTP warm-up runs through the ADR-025IWarmupTaskextension point (SelfHttpOutputCacheWarmupTaskon Conference,SelfHttpWarmupTaskon Identity and Engagement), whose shared base short-circuits under theTestingenvironment. - Non-Identity services use
AddForwardedJwtBearer(fetches{authority}/.well-known/...JWKS). A per-service WAF has no JWKS authority, so the factory post-configuresJwtBearerOptionswithJwtTokenGenerator.ConfigureInProcessTokenValidationto validate the test public key in-process. Identity itself usesAddCommonAuthentication(in-process): no override. - No host declares
public partial class Program;: the fixtures bindWebApplicationFactory<Program>to each host's top-level-statementsProgramdirectly (and through extern aliases in the cross-service project).
Databases
- SQL Server for the whole per-service tier (no SQLite tier): each fixture creates a throwaway
database (LocalDB by default,
ADC_TEST_SQL_BASEin CI against the job's SQL Server container), the host applies the schema withDatabaseInitStrategy=Migrate, Respawn resets data between tests, and the database is dropped on disposal. - The SQL-fidelity gaps (#8) are covered on that same engine: soft-delete filters
(
SoftDeleteFidelityTests), rowversion concurrency (OrganizerConcurrencyTests), audit stamping (AuditStampFidelityTests), the outbox (OutboxFidelityTests). Theef migrations has-pending-model-changesdrift check runs in thebuild-and-testjob ofdeploy.yml. - Testcontainers SQL Server backs only the cross-service tier.
- No
SQLServerDbContextsplit: per-service DB routing is config-only viaDataSources.
Project structure
- One WAF test project per service (
MMCA.ADC.{Identity,Conference,Engagement,Notification}.IntegrationTests): can't reference twoProgram-bearing hosts in one project. - One
MMCA.ADC.CrossService.IntegrationTestsfor the real-broker/real-gRPC tier, plusMMCA.ADC.ServiceBusEmulator.IntegrationTestsfor the Azure Service Bus emulator transport smoke. - The
MMCA.Common.APIexception-handler unit tests live inMMCA.Common.API.Testsin MMCA.Common, not in an ADCWebAPI.Testsproject. - Reuse
MMCA.Common.Testing:SqlServerIntegrationTestFixtureBase<TEntryPoint>,IntegrationTestBase<TFixture>,CrossServiceFixtureBaseandJwtTokenGenerator.
CI
- The per-service tier is
MMCA.ADC.Integration.slnf, run by the PR-onlyintegration-testsjob indeploy.yml(SQL Server container, no Docker-in-Docker). It is a required PR check, which restores the authz/CRUD merge gate (#11).MMCA.ADC.CI.slnfstays the unit, architecture and bUnit tier ofbuild-and-test. - The container-based SQL Server + RabbitMQ + Redis tier runs in a separate nightly job
(
cross-service-tests.yml), outsidedeploy.needsand enforced through thecross-service-freshnessdeploy gate.
Phased sequencing (fastest win first)
All six phases are done; each line names what shipped.
- Phase 0: the dead WebAPI reference is gone and the middleware unit tests live in
MMCA.Common.API.Tests(MMCA.Common); removes a non-building project (#16). - Phase 1: Identity WAF (simplest host) on the reusable
SqlServerIntegrationTestFixtureBase<TEntryPoint>; re-homed theAuth*/AttendeeClaims/OrganizerUsertests. Restores the auth/authz gate (#11). - Phase 2, Conference WAF: first use of the
JwtBearerOptionsoverride; the warm-up runs as aTesting-awareIWarmupTask;IBookmarkCountServicefaked; re-homed the CRUD/lifecycle/edge-case block. - Phase 3, Engagement WAF:
ISessionBookmarkValidationServicefaked; bookmark +OwnerOrAdminFiltertests. - Phase 4: SQL-fidelity subset (on the per-service SQL Server tier) + cross-service real-broker tier (BR-207, speaker-link, bookmark-count, backplane fan-out); the separate container CI job.
- Phase 5: integration coverage through
dotnet-coverage(cobertura, merged by the report-onlycoveragejob),slnx/Integration.slnf/CI.slnffinalized, the Testability row (section 14) recorded under Resolved inadc-RemediationBacklog.md.
Key risks
- The non-Identity
JwtBearerOptionsin-process override is the trickiest piece: prove it on one Conference auth test before fanning out. - Provider fidelity (owned types, soft-delete filters, rowversion): avoided by running the whole per-service tier on SQL Server rather than SQLite.
- Re-homing ~258 cross-module tests is the bulk of the effort: cross-module seeding becomes "seed-own-DB + fake-foreign-service"; genuine cross-module assertions move to the real-broker tier.
Critical files
Tests/Integration/MMCA.ADC.{Identity,Conference,Engagement,Notification}.IntegrationTests/Infrastructure/(<Service>IntegrationTestFixture.cs,<Service>TestWebApplicationFactory.cs,<Service>IntegrationTestBase.cswith the ADC seed/auth helpers, and theFake*gRPC stand-ins)Tests/Integration/MMCA.ADC.CrossService.IntegrationTests/Infrastructure/CrossServiceFixture.csand the per-host*CrossServiceFactory.csfilesSource/Services/MMCA.ADC.Conference.Service/Program.cs(SelfHttpOutputCacheWarmupTaskregistration +app.RunAsync())MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.Authentication.cs(AddForwardedJwtBearer/AddCommonAuthentication, the extension point the WAF overrides)MMCA.Common/Source/Hosting/MMCA.Common.Testing/Fixtures/SqlServerIntegrationTestFixtureBase.cs,Fixtures/IntegrationTestBase.cs,Fixtures/CrossServiceFixtureBase.cs,Support/JwtTokenGenerator.csMMCA.ADC.slnx,MMCA.ADC.Integration.slnf,MMCA.ADC.CI.slnf;.github/workflows/deploy.yml(integration-tests,coverage,freshness) and.github/workflows/cross-service-tests.yml