cranpose-testing 0.9.7

Composition, semantics, accessibility, and robot test utilities for Cranpose
docs.rs failed to build cranpose-testing-0.9.7
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: cranpose-testing-0.1.99

Cranpose Test Tools

cranpose-testing provides public test helpers for Cranpose compositions and app behavior. ComposeTestRule composes UI in memory; semantic queries and accessibility audits inspect the current tree. The robot API drives input against a headless or desktop app shell.

Test a composition

Add cranpose-testing as a development dependency with cargo add cranpose-testing --dev. Use ComposeTestRule for layout, state, semantics, and accessibility checks in an in-memory composition:

use cranpose::prelude::*;
use cranpose_testing::ComposeTestRule;

#[composable]
fn Greeting() {
    Text("Ready", Modifier::empty(), TextStyle::default());
}

let mut rule = ComposeTestRule::new();
rule.set_content(Greeting).expect("content composes");
let screen = rule
    .placed_semantics(Size::new(320.0, 120.0))
    .expect("layout succeeds")
    .expect("screen has content");
assert!(screen
    .flatten()
    .iter()
    .any(|node| node.label.as_deref() == Some("Ready")));

placed_semantics returns labels and bounds for a chosen viewport. assert_accessible checks the placed tree, and audit_accessibility returns structured issues for custom summaries.

Run robot tests

The desktop-robot feature enables helper queries and assertions. The app test target also selects cranpose/robot, desktop, and a renderer such as renderer-wgpu. A robot runner starts AppLauncher with with_headless(true) and supplies a with_test_driver closure. The driver waits for app work, queries semantics, sends input, and exits the app.

cargo add cranpose-testing --dev --features desktop-robot

Linux desktop robot runs need a display server; CI can run the test through xvfb-run. Headless composition tests use an in-memory applier and run on the CPU. The repository's run_robot_test.sh runs repository robot scenarios.

Links