Deterministic testing of atomr actors with atomr-testkit: TestProbe assertions and virtual-time TestScheduler for actor systems.
Ships in atomr-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
atomr-testkit provides the deterministic scaffolding that lets you
test actor systems without sleeping or racing. Reach for it whenever a
test exercises an ActorRef.
Enable it via the umbrella feature:
[dev-dependencies]
atomr = { version = "0.2", features = ["testkit"] }
# or directly:
atomr-testkit = "0.1"
TestProbe<M> is an actor whose mailbox you assert against directly.
Hand its actor_ref() to the system-under-test as if it were any other
collaborator; the probe records every message it receives so the test
body can pull them out.
use std::time::Duration;
use atomr::prelude::*;
use atomr::testkit::{TestKit, TestProbe};
#[tokio::test]
async fn greeter_replies() {
let system = ActorSystem::create("test", Config::empty()).await.unwrap();
let kit = TestKit::new(/* … */);
let mut probe: TestProbe<String> = kit.probe("greeter-replies");
// System under test: an actor that forwards a String to `probe`.
let greeter = system.actor_of(
Props::create({
let to = probe.actor_ref().clone();
move || ForwardActor { to: to.clone() }
}),
"greeter",
).unwrap();
greeter.tell("hi".to_string());
let msg = probe.expect_msg(Duration::from_secs(1)).await.unwrap();
assert_eq!(msg, "hi");
}
| Method | What it does |
|---|---|
expect_msg(timeout) | Pop the next message; error on timeout. |
expect_msg_pf(timeout, pred) | Pop the next message and require pred(&msg). |
expect_msg_class(timeout, extract) | Pop and run a destructuring closure. |
expect_no_msg(timeout) | Assert nothing arrives within timeout. |
receive_n(n, timeout) | Collect n messages or fail. |
Always pass a finite timeout. CI is slow; pick something forgiving
(e.g. Duration::from_secs(2)) rather than Duration::from_millis(50).
TestSchedulerTestScheduler replaces wall-clock scheduling with a manually-driven
clock. Use it whenever the code under test calls schedule_after,
debounces, or runs periodic work — wall-clock tokio::time::sleep in
tests is slow and flaky.
use std::time::Duration;
use atomr::testkit::TestScheduler;
#[tokio::test]
async fn debounce_fires_after_quiet_period() {
let sched = TestScheduler::new();
let token = sched.schedule_after(Duration::from_millis(500), || {
// … callback
});
assert!(!sched.fired(token));
sched.advance(Duration::from_millis(499)).await;
assert!(!sched.fired(token));
sched.advance(Duration::from_millis(1)).await;
assert!(sched.fired(token));
}
Cancel pending work with sched.cancel(token). Inspect outstanding
work with sched.pending().
For distributed tests (membership, sharding, persistence-tck) reach for
atomr_testkit::MultiNodeSpec. It boots multiple nodes in one test and
exposes barriers and event filters. See the integration tests in
crates/atomr-cluster/tests/ and crates/atomr-persistence-tck/ for
working examples.
When you need each node in its own OS process (to exercise real
serialization, transport, or signal handling), use
MultiNodeOopController plus MultiNodeOopNode. The controller spawns
node binaries and brokers a TCP-based barrier rendezvous; each node
calls MultiNodeOopNode::enter_barrier(name) to synchronize. This is
the same shape as MultiNodeSpec but across processes rather than
within one tokio runtime.
Many cross-runtime spec tests now live alongside their owning crates —
mirror their style when you add coverage for a new corner. Notable
ones: routing (RoutingSpec), streams (FlowOperatorSpec, HubSpec,
SubStreamSpec, rate operators conflate/expand,
merge_sorted/merge_prioritized, Queue, Restart), supervision
(Lifecycle, Stash, Recovery), runtime infrastructure
(Scheduler, Extensions, IO managers, ActorPath/Address,
ServiceContainer, Hosting, Lease).
If you implement a Journal or SnapshotStore, run it through
atomr-persistence-tck's journal_suite, journal_tag_suite, and
snapshot_suite. They are the source of truth for what "compatible
with atomr-persistence" means.
crates/atomr-testkit/src/probe.rs — TestProbe APIcrates/atomr-testkit/src/test_kit.rs — TestKit::probecrates/atomr-testkit/src/test_scheduler.rs — TestSchedulercrates/atomr-testkit/src/multinode.rs — MultiNodeSpecsleep in actor tests. Replace with TestScheduler
or with expect_msg_pf that polls until a predicate matches.let mut probe = …
in the test body, not inside a Props::create closure that gets
re-run on restart.expect_no_msg. The
scheduler may not have ticked yet; use longer windows (250ms+) or
drive the scheduler explicitly via TestScheduler::advance.ActorSystem before assertions complete. Keep the
system alive until the last assertion, then system.terminate().await.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/atomr-ai-skills:atomr-testingfrom atomr-ai-skills
npx claudepluginhub rustakka/atomr --plugin atomr-ai-skills6 skills in this plugin
/atomr-actor-designUse when authoring or modifying an actor in a project that depends on atomr. Covers Msg type design, the Actor trait's lifecycle hooks, ask vs tell, supervision strategies, and FSM patterns. Triggers on writing or editing an `impl Actor`, choosing a Msg enum, picking a supervision strategy, or wiring `Props`/`ActorSystem`./atomr-clusterUse when bringing up clustering, sharding, singleton, distributed pub/sub, or distributed-data (CRDT) features in a project that depends on atomr. Covers feature flag selection, seed-node bootstrap, MessageExtractor design for sharding, and DistributedPubSub patterns. Triggers when adding cluster membership, ShardRegion, ShardCoordinator, ClusterSingleton, or Replicator usage./atomr-persistenceUse when adding event sourcing to an actor in a project that depends on atomr. Covers the Eventsourced trait, journals, snapshots, recovery, RecoveryPermitter, AsyncSnapshotter, and choosing a storage adapter (sql / redis / mongodb / cassandra / aws / azure). Triggers when implementing PersistentActor or Eventsourced, configuring a Journal/SnapshotStore, or wiring a backend./atomr-pythonUse when working with atomr's Python bindings — authoring Python actors, choosing a GIL/dispatcher strategy (python-pinned / python-subinterpreter-pool / python-nogil / python-subprocess), using ask/tell from async or sync code, or declaring C-extension subinterpreter compatibility. Triggers when `pip install atomr`, `from atomr import …`, or any Python file calling `ActorSystem`, `Props`, `Actor`, etc./atomr-troubleshootingUse when diagnosing failures in a project that depends on atomr. Covers compile-time errors (missing feature flags, wrong prelude), runtime issues (mailbox stalls, restart loops, ask timeouts), and cluster-level problems (split-brain, unreachable members). Triggers on atomr error messages, missing-symbol errors, hangs, or repeated restarts.