backend-testing
Assists with writing robust backend integration tests using xUnit, FluentClient, and AppWebHostFactory in .NET.
Install
mkdir -p .claude/skills/backend-testing && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1901" && unzip -o skill.zip -d .claude/skills/backend-testing && rm skill.zipInstalls to .claude/skills/backend-testing
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use this skill when writing or modifying C# tests — unit tests, integration tests, or test fixtures. Covers xUnit patterns, AppWebHostFactory for integration testing, FluentClient for API assertions, ProxyTimeProvider for time manipulation, and test data builders. Apply when adding new test cases, debugging test failures, or setting up test infrastructure.Key capabilities
- →Write integration tests with AppWebHostFactory
- →Simulate time-dependent logic with ProxyTimeProvider
- →Generate test data using automated builders
- →Perform API assertions with FluentClient
How it works
Tests inherit from base classes like IntegrationTestsBase to access DI services, fluent HTTP clients, and time manipulation utilities.
Inputs & outputs
When to use backend-testing
- →Write integration tests using AppWebHostFactory
- →Generate test data with automated builders
- →Simulate time-dependent logic in tests
- →Implement xUnit tests for backend services
About this skill
Backend Testing
Test Naming Standards
Pattern: MethodUnderTest_Scenario_ExpectedBehavior
- MethodUnderTest — The actual method on the class being tested, not necessarily the entry point you call.
- Scenario — The input, state, or condition being tested.
- ExpectedBehavior — What the method should do or return.
// ✅ Good
[Fact]
public void GetValue_JObjectWithUserInfo_ReturnsTypedUserInfo() { }
[Fact]
public async Task PostEvent_WithValidPayload_ReturnsAccepted() { }
// ❌ Bad: Vague or wrong method name
[Fact]
public void TestGetValue() { }
[Fact]
public void Deserialize_EmptyArray_ReturnsEmptyList() { } // Wrong: name the method under test, not the entry point
Test Folder Structure
tests/Exceptionless.Tests/
├── AppWebHostFactory.cs # WebApplicationFactory for integration tests
├── IntegrationTestsBase.cs # Base class for integration tests
├── TestWithServices.cs # Base class for unit tests with DI
├── Api/ # Minimal API tests, organized by production layer
│ ├── Endpoints/ # HTTP integration tests by endpoint family
│ ├── Filters/ # Endpoint filter unit tests
│ ├── Handlers/ # Mediator handler unit tests
│ └── Results/ # API result mapping tests
├── Jobs/ # Job tests
├── Repositories/ # Repository tests
├── Services/ # Service tests
├── Utility/ # Test data builders
│ ├── AppSendBuilder.cs # Fluent HTTP request builder
│ ├── DataBuilder.cs # Test data creation
│ ├── ProxyTimeProvider.cs # Time manipulation
│ └── ...
└── Validation/ # Validator tests
Integration Test Base
Inherit from IntegrationTestsBase (extends Foundatio.Xunit's TestWithLoggingBase):
public abstract class IntegrationTestsBase : TestWithLoggingBase, IAsyncLifetime, IClassFixture<AppWebHostFactory>
Key members: GetService<T>(), CreateFluentClient(), SendRequestAsync(), RefreshDataAsync(), ResetDataAsync(), TimeProvider (ProxyTimeProvider).
HTTP Test Pattern
Use SendRequestAsync with AppSendBuilder for HTTP testing:
await SendRequestAsync(r => r
.Post()
.AsTestOrganizationUser()
.AppendPath("organizations")
.Content(new NewOrganization { Name = "Test" })
.StatusCodeShouldBeCreated()
);
Auth helpers: AsGlobalAdminUser(), AsTestOrganizationUser(), AsFreeOrganizationUser(), AsTestOrganizationClientUser() (API key bearer token).
Test Data Builders
var (stacks, events) = await CreateDataAsync(b => b
.Event()
.TestProject()
.Type(Event.KnownTypes.Error)
.Message("Test error"));
ProxyTimeProvider
NOT ISystemClock — use .NET 8+ TimeProvider with ProxyTimeProvider:
TimeProvider.Advance(TimeSpan.FromHours(1));
TimeProvider.SetUtcNow(new DateTimeOffset(2024, 1, 15, 12, 0, 0, TimeSpan.Zero));
TimeProvider.Restore();
Test Principles
- Regression coverage — Add a focused failing test first when a bug fix can be reproduced cheaply
- Use real serializer — Tests use the same JSON serializer as production
- Refresh after writes — Call
RefreshDataAsync()after database changes - Clean state —
ResetDataAsync()clears data between integration tests
When not to use it
- →When testing non-backend C# components
Prerequisites
Limitations
- →Requires .NET 8+ for TimeProvider usage
How it compares
It uses a standardized naming convention and specific base classes to ensure consistent test structure compared to ad-hoc xUnit implementations.
Compared to similar skills
backend-testing side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| backend-testing (this skill) | 3 | 28d | No flags | Intermediate |
| csharp-pro | 9 | 4mo | No flags | Intermediate |
| csharp-developer | 43 | 2mo | No flags | Advanced |
| performance-benchmark | 3 | 4mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by exceptionless
View all by exceptionless →You might also like
csharp-pro
sickn33
Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.
csharp-developer
zenobi-us
Expert C# developer specializing in modern .NET development, ASP.NET Core, and cloud-native applications. Masters C# 12 features, Blazor, and cross-platform development with emphasis on performance and clean architecture.
performance-benchmark
dotnet
Generate and run ad hoc performance benchmarks to validate code changes. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime.
dotnet-backend-patterns
wshobson
Master C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.
azure-servicebus-dotnet
microsoft
Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions, and sessions. Use for reliable message delivery, pub/sub patterns, dead letter handling, and background processing. Triggers: "Service Bus", "ServiceBusClient", "ServiceBusSender", "ServiceBusReceiver", "ServiceBusProcessor", "message queue", "pub/sub .NET", "dead letter queue".
azure-identity-dotnet
microsoft
Azure Identity SDK for .NET. Authentication library for Azure SDK clients using Microsoft Entra ID. Use for DefaultAzureCredential, managed identity, service principals, and developer credentials. Triggers: "Azure Identity", "DefaultAzureCredential", "ManagedIdentityCredential", "ClientSecretCredential", "authentication .NET", "Azure auth", "credential chain".