aspire-integration-testing

Write integration tests for .NET Aspire applications using xUnit fixtures and real dependencies.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill aspire-integration-testing-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: aspire-integration-testing
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/aspire-integration-testing
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill aspire-integration-testing-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing integration tests for distributed .NET applications is difficult because services need real databases, message brokers, and dynamic endpoints rather than mocks. This Skill provides patterns for using .NET Aspire's testing facilities with xUnit to spin up full application stacks in tests. ## Core Features & Use Cases - Test Fixture Patterns: Build xUnit fixtures with IAsyncLifetime that start a DistributedApplication, wait for health checks, and dispose cleanly. - Endpoint Discovery: Retrieve dynamic endpoints and connection strings at runtime instead of hard-coding URLs or ports. - Real Dependency Testing: Test against actual SQL Server, PostgreSQL, Redis, and RabbitMQ containers orchestrated by Aspire, including database reset with Respawn and Playwright UI tests. - Use Case: You need to verify that your ASP.NET Core API correctly reads from PostgreSQL and publishes to RabbitMQ. Use this Skill to create a fixture that starts the full Aspire AppHost, waits for health, and runs tests against real services. ## Quick Start Ask the AI to create an xUnit integration test fixture using DistributedApplicationTestingBuilder for your Aspire AppHost project.

Frequently Asked Questions about aspire-integration-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write integration tests for .NET Aspire applications?▼

Use the Aspire.Hosting.Testing package with xUnit to create a fixture implementing IAsyncLifetime. Build the app with DistributedApplicationTestingBuilder.CreateAsync, call StartAsync, then wait for resources to become healthy before running tests.

How to avoid hard-coded URLs in Aspire integration tests?▼

Discover endpoints dynamically at runtime using app.GetEndpoint or app.CreateHttpClient with the resource name. Aspire assigns ports dynamically, so hard-coded localhost URLs will break between runs.

Can I combine Playwright UI tests with Aspire integration tests?▼

Yes, create a fixture that starts both the DistributedApplication and a Playwright browser. Get the web app URL from the Aspire endpoint discovery, then drive the browser against the real running backend.

Why do my Aspire integration tests fail with file descriptor exhaustion on Linux?▼

Each test host enables configuration file watchers by default, exhausting inotify limits. Set DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE to false in a ModuleInitializer so it applies before any test host starts.

How do I reset the database between Aspire integration tests?▼

Use the Respawn library with the connection string retrieved via GetConnectionStringAsync. Configure tables to ignore such as migration history, then call ResetAsync between tests to restore a clean state.

Why do parallel xUnit tests conflict when sharing an Aspire app?▼

Tests running in parallel against the same application instance can interfere through shared databases or ports. Use xUnit CollectionDefinition with ICollectionFixture to share one fixture and force sequential execution within the collection.