← ClaudeAtlas

dotnet-testing-advanced-webapi-integration-testinglisted

Complete guide for ASP.NET Core Web API integration testing. Use when performing integration testing on Web API endpoints or validating ProblemDetails error format. Covers WebApplicationFactory, IExceptionHandler, Testcontainers multi-container orchestration, Flurl URL construction, and AwesomeAssertions HTTP validation. Keywords: webapi integration testing, WebApplicationFactory, asp.net core integration test, webapi integration test, IExceptionHandler, ProblemDetails, ValidationProblemDetails, AwesomeAssertions, Flurl, Respawn, Be201Created, Be400BadRequest, multi-container testing, Collection Fixture, global exception handling
rudironsoni/SharpClaw · ★ 1 · Testing & QA · score 59
Install: claude install-skill rudironsoni/SharpClaw
Source: kevintsengtw/dotnet-testing-agent-skills (MIT). Ported into dotnet-agent-harness. # Web API Integration Testing ## Applicable Scenarios **Skill Level**: Advanced **Prerequisites**: xUnit basics, ASP.NET Core basics, Testcontainers basics, Clean Architecture **Estimated Learning Time**: 60-90 minutes ## Learning Objectives After completing this skill, you will be able to: 1. Establish complete Web API integration testing architecture 2. Implement modern exception handling using `IExceptionHandler` 3. Validate standard `ProblemDetails` and `ValidationProblemDetails` format 4. Use Flurl to simplify URL construction for HTTP testing 5. Use AwesomeAssertions for precise HTTP response validation 6. Establish multi-container (PostgreSQL + Redis) testing environment ## Core Concepts ### IExceptionHandler - Modern Exception Handling The `IExceptionHandler` interface introduced in ASP.NET Core 8+ provides a more elegant error handling approach than traditional middleware: ````csharp /// <summary> /// Global exception handler /// </summary> public class GlobalExceptionHandler : IExceptionHandler { private readonly ILogger<GlobalExceptionHandler> _logger; public GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger) { _logger = logger; } public async ValueTask<bool> TryHandleAsync( HttpContext httpContext, Exception exception, CancellationToken cancellationToken) { _logger.LogError(exception,