integration-testing

Write .NET integration tests using WebApplicationFactory, TestContainers, and Respawn.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill integration-testing-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integration-testing
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/testing/integration-testing
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill integration-testing-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Integration tests can be flaky, slow, or tied to production services, making it hard to verify end-to-end behavior reliably; this Skill provides patterns to create isolated, repeatable integration tests that mirror production pipelines without external side effects.

Core Features & Use Cases

  • In-process test servers using WebApplicationFactory to exercise full HTTP/gRPC pipelines.
  • Fixture-based resource sharing with IClassFixture to speed tests and reuse expensive resources.
  • Containerized real databases via TestContainers and fast state resets with Respawn for realistic, repeatable scenarios.
  • Service overrides through ConfigureTestServices to replace external dependencies with fakes or test doubles.
  • Use Case: Add integration tests for an order service that validate handlers, persistence, and messaging while running a SQL container and resetting state between tests.

Quick Start

Run the integration-testing skill to scaffold or adapt a TestWebAppFactory with ConfigureTestServices to use an in-memory database or a TestContainers-backed database and a shared fixture for isolated end-to-end testing.

Frequently Asked Questions about integration-testing

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

FAQPage Schema
How do I set up reliable .NET integration tests with WebApplicationFactory?

Reliable .NET integration tests use WebApplicationFactory to host an in-process test server, exercising full HTTP and gRPC pipelines. You override external dependencies using ConfigureTestServices to replace them with fakes or test doubles, ensuring isolated and repeatable end-to-end verification without external side effects.

What's the best way to reset a database between .NET integration tests?

Database resets between .NET integration tests are handled efficiently using Respawn. By pairing Respawn with TestContainers to spin up containerized real databases, you achieve fast state resets that provide realistic, repeatable testing scenarios without leaving residual data from previous test runs.

How does IClassFixture improve integration test performance in .NET?

IClassFixture improves .NET integration test performance by enabling fixture-based resource sharing across test classes. It allows expensive resources, such as containerized databases or in-process test servers, to be initialized once and reused, significantly speeding up test execution while maintaining isolation.

Can I test gRPC services using in-process test servers in .NET?

Yes, you can test gRPC services using in-process test servers in .NET. By leveraging WebApplicationFactory, the integration testing approach exercises full HTTP and gRPC pipelines end-to-end, verifying service behavior through configured HTTP handlers within an isolated test environment.

Why are my integration tests flaky when using a shared database?

Integration tests become flaky when a shared database accumulates state from previous runs. Applying Respawn for fast state resets between tests ensures a clean database baseline. Combined with TestContainers for isolated containerized databases, this approach eliminates side effects and ensures repeatable results.

Do I need TestContainers to run .NET integration tests?

You do not need TestContainers if an in-memory database suffices, but TestContainers provides containerized real databases for realistic scenarios. Using TestContainers alongside Respawn ensures isolated test environments and repeatable database reset strategies, mirroring production pipelines accurately for end-to-end verification.