rust-testinglisted
Install: claude install-skill flowmux-ai/flowmux-terminal
# Rust testing (flowmux workspace)
Tests split into two worlds. Run the right harness or GUI/D-Bus tests
hang or fail spuriously.
## Headless crates — run bare
No GTK, no D-Bus. Fast. Default to these while iterating.
```bash
cargo test -p flowmux-core
cargo test -p flowmux-ipc -- --nocapture
cargo test -p flowmux-config
cargo test -p flowmux-state
```
## GTK / D-Bus crates — mirror CI
Crates that open GTK or D-Bus (the `flowmux` GUI crate, notifier paths)
need a virtual display and a session bus. Mirror CI exactly:
```bash
xvfb-run -a dbus-run-session -- cargo test --workspace --locked -- --nocapture
```
- `xvfb-run -a` — headless X server (auto-picks a free display).
- `dbus-run-session` — private session bus so `org.gtk.Notifications`
tests don't touch the real desktop.
- `--locked` — fail if `Cargo.lock` would change (CI parity).
## Single test / filter
`cargo test` takes a substring filter:
```bash
cargo test -p flowmux-core title_is_shell_cwd_echo # one test by name
cargo test -p flowmux-core pane_tree # all matching substring
cargo test -p flowmux-core -- --exact path::to::test # exact path
cargo test -p flowmux-core -- --ignored # run #[ignore]d ones
```
`-- --nocapture` shows `println!`/`dbg!` output; `-- --test-threads=1`
serializes when a test touches shared global/env state.
## Writing tests — house style
- **Unit tests inline** under `#[cfg(test)] mod tests { … }` at the
bottom of the file (see `flowmux-core/src/li