From kagents
.NET Aspire integration testing — DistributedApplicationTestingBuilder, AppHost test fixtures, service mocking, health check validation, TUnit with ClassDataSource. USE FOR: writing and debugging integration tests against Aspire-orchestrated services. DO NOT USE FOR: Aspire app configuration (use aspire-architecture) or unit tests without Aspire (use tunit-patterns).
How this skill is triggered — by the user, by Claude, or both
Slash command
/kagents:aspire-integration-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Adaptiert von: [Aaronontheweb/dotnet-skills](https://github.com/Aaronontheweb/dotnet-skills) (MIT)
Adaptiert von: Aaronontheweb/dotnet-skills (MIT) Angepasst für TUnit (nicht xUnit wie im Original).
<PackageReference Include="Aspire.Hosting.Testing" Version="*" />
<PackageReference Include="TUnit" Version="*" />
public class AspireAppFixture : IAsyncDisposable
{
public DistributedApplication App { get; private set; } = null!;
public HttpClient ApiClient { get; private set; } = null!;
public AspireAppFixture()
{
var builder = await DistributedApplicationTestingBuilder
.CreateAsync<Projects.MyApp_AppHost>();
// Optional: Services mocken oder konfigurieren
builder.Services.ConfigureHttpClientDefaults(http =>
http.AddStandardResilienceHandler());
App = await builder.BuildAsync();
await App.StartAsync();
ApiClient = App.CreateHttpClient("api");
}
public async ValueTask DisposeAsync()
{
await App.DisposeAsync();
ApiClient.Dispose();
}
}
[Test]
[ClassDataSource<AspireAppFixture>(Shared = SharedType.PerTestSession)]
public async Task Api_HealthCheck_ReturnsHealthy(AspireAppFixture app)
{
var response = await app.ApiClient.GetAsync("/health");
await Assert.That((int)response.StatusCode).IsEqualTo(200);
}
[Test]
[ClassDataSource<AspireAppFixture>(Shared = SharedType.PerTestSession)]
public async Task Api_GetUsers_ReturnsData(AspireAppFixture app)
{
var response = await app.ApiClient.GetAsync("/api/users");
response.EnsureSuccessStatusCode();
var users = await response.Content.ReadFromJsonAsync<List<UserResponse>>();
await Assert.That(users).IsNotNull();
}
// Dashboard-URL für Debugging
var dashboardUrl = App.GetEndpoint("aspire-dashboard");
// Logs und Traces live beobachten während Tests laufen
PerTestSession Shared Scope um AppHost nur einmal zu startenCreateHttpClient("service-name") nutzt Service DiscoveryCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub grexyloco/k.agents