Setting the file. One moment. Testing Performance And Operations · ASP.NET Core · openai/skills · Skills DocsUse layered testing instead of relying on one style:
- unit tests for pure services and business logic
- integration tests for request pipeline, DI, database, auth, and framework wiring
- browser tests for end-to-end user flows
Use Microsoft.AspNetCore.Mvc.Testing and WebApplicationFactory<Program> for integration tests.
Guidance from the official docs:
- use a test host and
HttpClient
- replace services with test doubles when needed
- control redirects when asserting auth behavior
- handle antiforgery correctly for form posts
- prefer SQLite in-memory over the EF Core in-memory provider for more realistic database tests
For SPA or browser-driven scenarios, Microsoft recommends browser automation such as Playwright for .NET.
Reach for built-in features before custom optimization layers:
- output caching
- response caching where appropriate
- response compression
- HTTP request timeouts
- rate limiting
- static file handling
General performance guidance:
- measure first
- keep database and network round trips visible
- reduce payload size
- use streaming or pagination when data is large
- keep synchronous blocking out of hot paths
Add health checks for dependencies that matter operationally.
Use separate checks or tags when you need:
- liveness
- readiness
- dependency-specific health surfaces
- structured logs
- request tracing where applicable
- metrics for critical paths such as auth, API latency, and background work
dotnet publish
- deploy the publish output
- run behind a process manager
- place a reverse proxy in front when the environment requires it
Know the deployment environment:
- IIS or Windows Service on Windows
- Kestrel plus Nginx or another reverse proxy on Linux
- container hosting when the platform expects it
Behind proxies or load balancers:
- configure forwarded headers
- validate scheme, host, and remote IP behavior
- test auth redirects and callback URLs in the deployed topology
- add health checks for databases and critical external services
- fail fast on invalid configuration where possible
- keep secrets out of publish artifacts
- verify data-protection key persistence in multi-instance deployments
references/testing-performance-and-operations.md