#[dbg_test] attribute macro wraps a standard Rust test so that its execution is recorded as a dbgflow session. When the test completes — whether it passes or panics — the session is persisted to disk. In the browser UI, the test appears as a node linked to the last traced function it called, making it easy to see exactly where an assertion failure originated.
Usage
Replace#[test] with #[dbg_test], or add it alongside #[test]:
#[test] is not already present, #[dbg_test] adds it automatically. You do not need both attributes.
Arguments
Optional display label for the test node shown in the browser UI. Defaults to the test function name.
How sessions are saved
#[dbg_test] persists the session when the DBG_SESSION_DIR environment variable is set to a writable directory path. You do not need to set this variable manually — the dbgflow test CLI command sets it automatically before running cargo test:
artifacts/test-sessions/run-<timestamp>/ by default. Each test that uses #[dbg_test] produces one JSON file in that directory. You can override the output directory with --output-dir:
If
DBG_SESSION_DIR is not set, the test still runs normally and the session is captured in memory — it is just not written to disk. This means #[dbg_test] is safe to use in any environment, even without the CLI.How test nodes are linked in the UI
When a#[dbg_test] test calls one or more #[trace] functions and then fails, the browser UI draws a test_link edge from the test node to the last traced function that was active before the failure. This lets you click the test node and immediately navigate to the function where the failure was rooted.
The test node is color-coded: green for a passing test, red for a failing one.
Example
The following example shows a test that calls a traced function and fails an assertion:increment function node.