Test application boundaries
Integration tests are most useful when they keep the application's real workflow but replace the slow or nondeterministic edge. Choose a focused guide for the boundary being controlled:
- Outbound HTTP: exact request matching, response sequences, faults, recording, verification, and controller-to-database workflows.
- Published messages: Kafka, Azure Service Bus, Notification Hubs, custom transports, typed payload assertions, and failure diagnostics.
- Observability: structured logs, activities, metrics, deterministic time, and scenario failure capture.
- Azure SDK clients: responses, paging, credentials, DI replacement, real SDK pipelines, retries, and request verification.
- Entity Framework Core: provider choice, database actions, lifecycle, isolation, and cleanup.
Combine boundaries in one scenario
A realistic workflow may read an outbound HTTP response, write database state, publish an event, and emit telemetry. Build all replacements into one factory and register stateful test doubles as scenario resources. Each test should then:
- Arrange only the remote responses needed by that scenario.
- Create a fresh
TestScenarioScope. - Call the application through its public HTTP endpoint.
- Assert the response and durable state first.
- Verify outbound calls, messages, logs, activities, and metrics that are part of the contract.
- Dispose the scope so resources reset and diagnostics are captured on failure.
Keep assertions at the application boundary. For example, assert the logical message destination and payload in a controller test, then use a smaller adapter or container test for broker-specific serialization. Likewise, use an HTTP stub for a typed-client workflow and a separate live-service test only for behavior that cannot be represented by the remote contract.
Scenario isolation and diagnostic collection are explained in scenarios and isolation and resources and cleanup. Authentication setup is covered in the authentication concept.
Browse the package API index for the entry points used at each boundary.