Kael ships first-class test infrastructure alongside the framework itself. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Augani/kael/llms.txt
Use this file to discover all available pages before exploring further.
test-support feature flag unlocks a TestAppContext that replaces the real foreground and background executors with a deterministic in-process scheduler. This means your tests exercise real entity mutations, real subscriptions, and real async tasks — without flakiness from OS scheduling or real timers. Because the output of the #[kael::test] macro is a standard Rust test function, every existing test runner — cargo test, cargo-nextest, and others — works without any configuration changes.
Enabling test support
Add thetest-support feature to your [dev-dependencies]:
toml
The #[kael::test] macro
Annotate any async test function with #[kael::test]. The macro injects a TestAppContext (or multiple, for collaborative UI tests) and wires up the deterministic executor:
rust
rust
Writing unit tests for entities
Usecx.update to interact with the app context from inside a test. Create entities, mutate them, and assert on their state:
Observing entities with observe
The kael::test::observe helper converts entity change notifications into a futures::Stream so you can await them inside an async test:
rust
observe returns an Observation<T> which holds a Subscription internally. When the Observation is dropped, the subscription is cancelled automatically.
Simulating events in tests
The deterministic executor lets you advance time or flush pending tasks explicitly. Combine this withcx.update to simulate sequences of UI events:
rust
Controlling randomness and retries
The test runner insidekael::test supports seed-based iteration for fuzz-style tests. You can override the seed and iteration count with environment variables:
bash
SEED=42 to reproduce the failure deterministically.
Running tests
The
worker_process and extension_process integration tests spin up real child processes and verify the full IPC transport path. They are slower than unit tests and require the host binary to be built first. Run them before cutting a release.Reference
| Symbol | Location | Purpose |
|---|---|---|
TestAppContext | kael::TestAppContext | Drop-in replacement for AppContext backed by a deterministic executor |
TestDispatcher | kael::TestDispatcher | Seed-driven scheduler used internally by run_test |
observe | kael::test::observe | Converts entity notifications into a futures::Stream |
Observation<T> | kael::test::Observation | Stream wrapper that cancels its subscription on drop |
run_test | kael::test::run_test | Low-level harness; prefer the #[kael::test] macro |
#[kael::test] | kael-macros | Proc-macro that injects TestAppContext and wires the executor |