akka-aspire-configurat…
Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering,…
Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit.
Claude Code
$ npx -y skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns --agent claude-code
Codex
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a codex -y
Cursor
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a cursor -y
Gemini CLI
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a gemini-cli -y
GitHub Copilot
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a github-copilot -y
OpenCode
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a opencode -y
Windsurf
$ npx skills add aaronontheweb/dotnet-skills --skill akka-testing-patterns -a windsurf -y
name: akka-net-testing-patterns description: Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit. user-invocable: false
Use this skill when:
**When:**
**Advantages:**
**When:**
See [anti-patterns-and-reference.md](anti-patterns-and-reference.md) for traditional TestKit patterns.
---
1. **Inherit from `Akka.Hosting.TestKit.TestKit`** - This is a framework base class, not a user-defined one 2. **Override `ConfigureServices()`** - Replace real services with fakes/mocks 3. **Override `ConfigureAkka()`** - Configure actors using the same extension methods as production 4. **Use `ActorRegistry`** - Type-safe retrieval of actor references 5. **Composition over Inheritance** - Fake services as fields, not base classes 6. **No Custom Base Classes** - Use method overrides, not inheritance hierarchies 7. **Test One Actor at a Time** - Use TestProbes for dependencies 8. **Match Production Patterns** - Same extension methods, different `AkkaExecutionMode`
---
<ItemGroup> <!-- Core testing framework --> <PackageReference Include="Akka.Hosting.TestKit" Version="*" /> <!-- xUnit (or your preferred test framework) --> <PackageReference Include="xunit" Version="*" /> <PackageReference Include="xunit.runner.visualstudio" Version="*" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="*" /> <!-- Assertions (recommended) --> <PackageReference Include="FluentAssertions" Version="*" /> <!-- In-memory persistence for testing --> <PackageReference Include="Akka.Persistence.Hosting" Version="*" /> <!-- If testing cluster sharding --> <PackageReference Include="Akka.Cluster.Hosting" Version="*" /> </ItemGroup>
---
Akka.Hosting.TestKit spins up real `IHost` instances, which by default enable file watchers for configuration reload. When running many tests, this exhausts file descriptor limits on Linux (inotify watch limit).
**Add this to your test project - it runs before any tests execute:**
// TestEnvironmentInitializer.cs
using System.Runtime.CompilerServices;
namespace YourApp.Tests;
internal static class TestEnvironmentInitializer
{
[ModuleInitializer]
internal static void Initialize()
{
// Disable config file watching in test hosts
// Prevents file descriptor exhaustion (inotify watch limit) on Linux
Environment.SetEnvironmentVariable("DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE", "false");
}
}**Why this matters:**
---
Each pattern below has a condensed description. See [examples.md](examples.md) for complete code samples.
The foundation pattern. Override `ConfigureServices()` to inject fakes, override `ConfigureAkka()` to register actors with the same extension methods as production.
public class OrderActorTests : TestKit
{
private readonly FakeOrderRepository _fakeRepository = new();
protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services)
{
services.AddSingleton<IOrderRepository>(_fakeRepository);
}
protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IServiceProvider provider)
{
builder.WithInMemoryJournal().WithInMemorySnapshotStore();
builder.WithActors((system, registry, resolver) =>
{
registry.Register<OrderActor>(system.ActorOf(resolver.Props<OrderActor>(), "order-actor"));
});
}
[Fact]
public async Task CreateOrder_Success_SavesToRepository()
{
var orderActor = ActorRegistry.Get<OrderActor>();
var response = await orderActor.Ask<OrderCommandResult>(
new CreateOrder("ORDER-123", "CUST-456", 99.99m), RemainingOrDefault);
response.Status.Should().Be(CommandStatus.Success);
_fakeRepositorA comprehensive AI coding plugin with 30 skills and 5 specialized agents for professional .NET development. Battle-tested patterns from production systems covering C#, Akka.NET, Aspire, EF Core, testing, and performance optimization.
Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering,…
Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs…
Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding…
Akka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster…
Guidelines for making .NET libraries and applications trimming-safe and Native AOT compatible. Covers the trimming/AOT model, the…
Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.