Agent skill

Akka.NET Testing Patterns

by Aaronontheweb in Aaronontheweb/dotnet-skills

Shows how to test Akka.NET actors with Akka.Hosting.TestKit: swapping services for fakes, using TestProbes, and checking persistence, plus when the older TestKit still fits.

MITAuto-check passedTesting & QA

Install Akka.NET Testing Patterns

skills CLI
$ npx skills add Aaronontheweb/dotnet-skills --skill akka-net-testing-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Aaronontheweb/dotnet-skills akka-net-testing-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Aaronontheweb/dotnet-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/akka-testing-patterns .claude/skills/akka-net-testing-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
akka-net-testing-patterns
GitHub stars
1.2k
Used in
1 other repo
Token cost
~2.4k tokens
SKILL.md length
785 words
Files
3
Skills in repo
33
Repo updated
First seen
Licence
MIT

At a glance

Shows how to test Akka.NET actors with Akka.Hosting.TestKit: swapping services for fakes, using TestProbes, and checking persistence, plus when the older TestKit still fits.

  • Works in 8 steps: Inherit from… → Override ConfigureServices() - Replace… → Override ConfigureAkka() - Configure… → …
  • Writing unit tests for Akka.NET actors that take injected services
  • SKILL.md covers When to Use This Skill, Reference Files, Choosing Your Testing Approach and Core Principles…, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

This skill steers tests for Akka.NET actors toward Akka.Hosting.TestKit, which it recommends for roughly 95% of cases: modern .NET applications that already use Microsoft.Extensions.DependencyInjection and configure actors through Akka.Hosting. A test class inherits the framework's TestKit base class, overrides ConfigureServices() to replace real services with fakes, and overrides ConfigureAkka() to wire actors with the same extension methods production uses.

The remaining principles are to fetch actor references through the type-safe ActorRegistry, keep fake services as fields instead of building custom base classes, and test one actor at a time with TestProbes standing in for its dependencies. Two reference files hold complete code samples for eight numbered patterns plus the anti-patterns. The traditional Akka.TestKit approach is kept for work on the Akka.NET core library, environments without Microsoft.Extensions, and legacy code that builds actors by hand with Props.

When your agent uses it

  • Writing unit tests for Akka.NET actors that take injected services
  • Testing persistent actors and their recovery from stored events
  • Checking message flows between actors with TestProbes
  • Deciding between Akka.Hosting.TestKit and the traditional TestKit

Example prompts

  • “Write tests for my OrderActor using Akka.Hosting.TestKit and a fake payment service.”
  • “Add a persistence test showing the cart actor restores its state after a restart.”
  • “Should this console app use the traditional Akka.TestKit or Akka.Hosting.TestKit?”

Requirements

  • A .NET project using Akka.NET v1.5 or later with Akka.Hosting

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit e426ed9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp and xml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Akka.NET Testing Patterns loads about 2.4k tokens when it runs. Until then it costs about 69 tokens; SKILL.md has 785 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~69
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Aaronontheweb/dotnet-skills at commit e426ed9, republished under its MIT licence (© Aaronontheweb). 785 words, ~2,442 tokens.

Download SKILL.mdSave it as .claude/skills/akka-net-testing-patterns/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
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.
invocable
false

Akka.NET Testing Patterns

When to Use This Skill

Use this skill when:

  • Writing unit tests for Akka.NET actors
  • Testing persistent actors with event sourcing
  • Verifying actor interactions and message flows
  • Testing actor supervision and lifecycle
  • Mocking external dependencies in actor tests
  • Testing cluster sharding behavior locally
  • Verifying actor state recovery and persistence

Reference Files

Choosing Your Testing Approach

When:

  • Building modern .NET applications with Microsoft.Extensions.DependencyInjection
  • Using Akka.Hosting for actor configuration in production
  • Need to inject services into actors (IOptions, DbContext, ILogger, HTTP clients, etc.)
  • Testing applications that use ASP.NET Core, Worker Services, or .NET Aspire
  • Working with modern Akka.NET projects (Akka.NET v1.5+)

Advantages:

  • Native dependency injection support - override services with fakes in tests
  • Configuration parity with production (same extension methods work in tests)
  • Clean separation between actor logic and infrastructure
  • Type-safe actor registry for retrieving actors
Use Traditional Akka.TestKit

When:

  • Contributing to Akka.NET core library development
  • Working in environments without Microsoft.Extensions (console apps, legacy systems)
  • Legacy codebases using manual Props creation without DI

See anti-patterns-and-reference.md for traditional TestKit patterns.


Core Principles (Akka.Hosting.TestKit)

  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

Required NuGet Packages

xml
<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>

CRITICAL: File Watcher Fix for Test Projects

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:

csharp
// 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:

  • [ModuleInitializer] runs automatically before any test code
  • Sets the environment variable globally for all IHost instances
  • Prevents cryptic inotify errors when running 100+ tests
  • Also applies to Aspire integration tests that use IHost

Testing Patterns Overview

Each pattern below has a condensed description. See examples.md for complete code samples.

Pattern 1: Basic Actor Test

The foundation pattern. Override ConfigureServices() to inject fakes, override ConfigureAkka() to register actors with the same extension methods as production.

csharp
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);
        _fakeRepository.SaveCallCount.Should().Be(1);
    }
}
Pattern 2: TestProbe for Actor Interactions

Register a TestProbe in the ActorRegistry as a stand-in for a dependency actor. Use ExpectMsgAsync<T>() to verify messages were sent.

Pattern 3: Auto-Responding TestProbe

When the actor under test uses Ask to communicate with dependencies, create an auto-responder actor that forwards messages to a probe AND replies to avoid timeouts.

Show full SKILL.md (319 more words)Show less
Pattern 4: Testing Persistent Actors

Use WithInMemoryJournal() and WithInMemorySnapshotStore(). Test recovery by killing the actor with PoisonPill and querying to force recovery from journal.

Pattern 5: Reuse Production Configuration

Always reuse production extension methods in tests instead of duplicating HOCON config. This ensures tests use the exact same configuration as production.

csharp
protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IServiceProvider provider)
{
    builder
        .AddDraftSerializer()                                    // Same as production
        .AddOrderDomainActors(AkkaExecutionMode.LocalTest)      // Same, but local mode
        .WithInMemoryJournal().WithInMemorySnapshotStore();      // Test-specific overrides
}
Pattern 6: Cluster Sharding Locally

Use AkkaExecutionMode.LocalTest with GenericChildPerEntityParent to test sharding behavior without an actual cluster. Same extension methods, different mode.

Pattern 7: AwaitAssertAsync for Async Operations

Use AwaitAssertAsync when actors perform async operations. It retries assertions until they pass or timeout, preventing flaky tests.

csharp
await AwaitAssertAsync(() =>
{
    _fakeReadModelService.SyncCallCount.Should().BeGreaterOrEqualTo(1);
}, TimeSpan.FromSeconds(3));
Pattern 8: Scenario-Based Integration Tests

Test complete business workflows end-to-end with multiple actors and state transitions. Register all domain actors, verify state at each step.


Common Patterns Summary

PatternUse Case
Basic Actor TestSingle actor with injected services
TestProbeVerify actor sends messages to dependencies
Auto-ResponderAvoid Ask timeouts when testing
Persistent ActorTest event sourcing and recovery
Cluster ShardingTest sharding behavior locally
AwaitAssertAsyncHandle async operations in actors
Scenario TestsEnd-to-end business workflows

Best Practices

  1. One test class per actor - Keep tests focused
  2. Override ConfigureServices/ConfigureAkka - Don't create base classes
  3. Use fakes, not mocks - Simpler, more maintainable
  4. Test one actor at a time - Use TestProbes for dependencies
  5. Match production patterns - Same extension methods, different AkkaExecutionMode
  6. Use AwaitAssertAsync for async - Prevents flaky tests
  7. Test recovery - Kill and restart actors to verify persistence
  8. Scenario tests for workflows - Test complete business flows end-to-end
  9. Keep tests fast - In-memory persistence, no real databases
  10. Use meaningful names - Scenario_FirstTimePurchase_SuccessfulPayment

Debugging Tips

  1. Enable debug logging - Pass LogLevel.Debug to TestKit constructor
  2. Use ITestOutputHelper - See actor system logs in test output
  3. Inspect TestProbe - Check probe.Messages to see what was sent
  4. Query actor state - Add state query messages for debugging
  5. Use AwaitAssertAsync with logging - See why assertions fail
  6. Check ActorRegistry - Verify actors are registered correctly
csharp
// Constructor with debug logging
public OrderActorTests(ITestOutputHelper output)
    : base(output: output, logLevel: LogLevel.Debug)
{
}

© Aaronontheweb, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in skills/akka-testing-patterns of Aaronontheweb/dotnet-skills.

  • SKILL.md
  • anti-patterns-and-reference.md
  • examples.md

Open the folder on GitHubat commit e426ed9

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in Aaronontheweb/dotnet-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Akka.NET Testing Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Akka.NET Testing Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Akka.NET Testing Patterns this skillAaronontheweb/dotnet-skills1.2k1 repos~2.4kAutomated safety check: PassMIT
Aspire Integration TestingDevBetterCom/DevBetterWeb1572 repos~2.3kAutomated safety check: PassNone
Dotnet Testingnovotnyllc/dotnet-artisan233—~972Automated safety check: PassMIT
Csharp Testingaffaan-m/ECC275k1 repos~2.2kAutomated safety check: PassMIT
Fsharp Testingaffaan-m/ECC275k1 repos~2kAutomated safety check: PassMIT
New Event Sourceaws/aws-lambda-dotnet1.7k—~3kAutomated safety check: PassApache-2.0

Similar skills

  • Aspire Integration Testing

    DevBetterCom/DevBetterWeb

    Write integration tests using .NET Aspire's testing facilities with xUnit.

    157 GitHub starsUsed in 2 repos~2.3k tokens
    Testing & QAAuto-check passed
  • Dotnet Testing

    novotnyllc/dotnet-artisan

    Defines .NET test strategy and implementation patterns across xUnit v3 (Facts, Theories, fixtures, IAsyncLifetime), integration testing (WebApplicationFactory, Testcontainers), Aspire testing…

    233 GitHub stars~972 tokensUpdated today
    Testing & QAAuto-check passed
  • Csharp Testing

    affaan-m/ECC

    C and .NET testing patterns with xUnit, FluentAssertions, mocking, integration tests, and test organization best practices.

    275k GitHub starsUsed in 1 repo~2.2k tokens
    Testing & QAAuto-check passed
  • Fsharp Testing

    affaan-m/ECC

    F testing patterns with xUnit, FsUnit, Unquote, FsCheck property-based testing, integration tests, and test organization best practices.

    275k GitHub starsUsed in 1 repo~2k tokens
    Testing & QAAuto-check passed
  • New Event Source

    aws/aws-lambda-dotnet

    Official

    Add a new AWS event source attribute (e.g., Kinesis, Kafka, MQ) to the Lambda .NET Annotations framework, including the attribute class, source generator integration, CloudFormation writer, unit…

    1.7k GitHub stars~3k tokensUpdated today
    Testing & QAAuto-check passed
  • Designing Tests

    CloudAI-X/claude-workflow-v2

    Designs and implements testing strategies for any codebase. An agent skill from CloudAI-X/claude-workflow-v2.

    1.4k GitHub starsUsed in 1 repo~1.5k tokens
    Testing & QAAuto-check passed

More from Aaronontheweb/dotnet-skills

All 33 skills in this repo
  • .NET API Compatibility Design

    Aaronontheweb/dotnet-skills

    Applies extend-only design rules to NuGet packages and distributed systems, covering source, binary and wire compatibility and how to deprecate members safely.

    1.2k GitHub starsUsed in 2 repos~2.7k tokens
    Auto-check passed
  • .NET Trimming and Native AOT

    Aaronontheweb/dotnet-skills

    Guides making .NET libraries trimming-safe and Native-AOT compatible: the MSBuild properties, trimming attributes, warning codes and a playbook of safe patterns.

    1.2k GitHub stars~2.9k tokensUpdated 20 days ago
    Auto-check passed
  • Akka.Hosting Actor Patterns

    Aaronontheweb/dotnet-skills

    Shows how to build entity actors with Akka.Hosting so the same code runs in local unit tests and in a sharded cluster in production.

    1.2k GitHub starsUsed in 1 repo~5k tokens
    Auto-check passed
  • Akka.NET Best Practices

    Aaronontheweb/dotnet-skills

    Guidance for Akka.NET actor systems covering EventStream versus DistributedPubSub, supervision, Props versus DependencyResolver, work distribution and testable cluster code.

    1.2k GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Akka.NET Management and Discovery

    Aaronontheweb/dotnet-skills

    Sets up Akka.Management and Cluster.Bootstrap so Akka.NET clusters form through service discovery on Kubernetes, Azure or config instead of static seed nodes.

    1.2k GitHub starsUsed in 1 repo~2.5k tokens
    Auto-check passed
  • .NET Aspire Explicit Configuration

    Aaronontheweb/dotnet-skills

    Wires .NET Aspire AppHost resources into explicit environment-variable configuration, keeping application code free of Aspire client packages and service discovery.

    1.2k GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed

Categories

Questions about Akka.NET Testing Patterns

What does Akka.NET Testing Patterns do?

Shows how to test Akka.NET actors with Akka.Hosting.TestKit: swapping services for fakes, using TestProbes, and checking persistence, plus when the older TestKit still fits. Hosting. A test class inherits the framework's TestKit base class, overrides ConfigureServices() to replace real services with fakes, and overrides ConfigureAkka() to wire actors with the same extension methods production uses.

When should I use Akka.NET Testing Patterns?

Akka.NET Testing Patterns fits situations like: writing unit tests for Akka.NET actors that take injected services; testing persistent actors and their recovery from stored events; checking message flows between actors with TestProbes; deciding between Akka.Hosting.TestKit and the traditional TestKit.

How do I install Akka.NET Testing Patterns in Claude Code?

Run `npx skills add Aaronontheweb/dotnet-skills --skill akka-net-testing-patterns -a claude-code`. Or copy the skill folder (skills/akka-testing-patterns in Aaronontheweb/dotnet-skills) into .claude/skills/akka-net-testing-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Akka.NET Testing Patterns in Codex?

Run `npx skills add Aaronontheweb/dotnet-skills --skill akka-net-testing-patterns -a codex`. Or copy the skill folder (skills/akka-testing-patterns in Aaronontheweb/dotnet-skills) into .agents/skills/akka-net-testing-patterns in your project. Codex loads it when a task matches its description.

Can I use Akka.NET Testing Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Aaronontheweb/dotnet-skills --skill akka-net-testing-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/akka-net-testing-patterns, .gemini/skills/akka-net-testing-patterns, .github/skills/akka-net-testing-patterns and .opencode/skills/akka-net-testing-patterns in your project.

What does Akka.NET Testing Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: Akka.NET Testing Patterns is instructions for the agent only. Our summary lists: A .NET project using Akka.NET v1.5 or later with Akka.Hosting.

Does Akka.NET Testing Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Akka.NET Testing Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Akka.NET Testing Patterns use?

Akka.NET Testing Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Akka.NET Testing Patterns use?

About 2.4k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Akka.NET Testing Patterns?

Skills that share tags, products or a category with Akka.NET Testing Patterns: Aspire Integration Testing (DevBetterCom/DevBetterWeb, 157 stars), Dotnet Testing (novotnyllc/dotnet-artisan, 233 stars), Csharp Testing (affaan-m/ECC, 275k stars) and Fsharp Testing (affaan-m/ECC, 275k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Akka.NET Testing Patterns?

Aaronontheweb (a GitHub user) maintains it in Aaronontheweb/dotnet-skills, which has 1,203 GitHub stars. The repository holds 33 skills in this directory. The repository was last updated on September 17, 2026.

Source: Aaronontheweb/dotnet-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.