Skip to content
  1. Docs
  2. Apps
  3. Developers

Testing apps

How app test suites are organized and run, what they focus on, and the conventions that keep a green run meaningful.

Each app carries its own test suite. Use the commands in its README (see Building and running an app).

Run the checks

From an app checkout, run the pinned test graph. Enable the features the app’s README specifies for the behavior you are checking.

sh
cargo test --locked
cargo clippy --locked --all-targets --all-features -- -D warnings

Pass a test-name filter to run part of a suite. Check that the command matched the intended test before using its result.

Conventions

Headless rendering

Tests render with the software backend so they run without a GPU or display:

sh
export ICED_TEST_BACKEND=software

Normal builds keep the native GPU renderer.

Serial by default

Many suites run with --test-threads=1. Fault injection, runtime registries and real resources such as PTYs are shared within a process, and Terminal's real-PTY tests would otherwise exceed the process file-descriptor limit.

Keep native integration tests in a private desktop session. Remote’s README runs its native cases sequentially because they share GLib and SDL state.

Test behaviour, not shape

Suites concentrate on user flows, data integrity and ownership boundaries, rather than on helpers, individual widgets or source shape. Typical retained contracts are:

  • document and data custody: atomic and conflicting saves, line-ending fidelity, refusal to overwrite, recovery after a failed save;
  • persistence: bounded and versioned reads, migration, stale completions arriving after newer work;
  • identity and credentials: account isolation, credential publication and removal, secrets never reaching snapshots or diagnostics;
  • desktop boundaries: URI parsing, single-instance activation, chooser cancellation, refusal of stale parents;
  • localization: every key resolves in every shipped locale, and a real surface renders in a non-English subprocess.

Prefer extending an existing boundary test over adding another standalone case, and keep cases separate only when their failure consequences differ.

Fixtures, not real services

Tests never use real accounts, send real mail or mutate real mailboxes. Apps use in-memory stores, synthetic accounts and bounded loopback servers instead:

  • Mail runs against synthetic accounts and local loopback servers.
  • Messages ships a messages-test-server crate with account-free wire fixtures for each protocol adapter. It checks the adapters' real HTTP requests, not network cryptography.
  • Video plays a real fixture file with several audio and subtitle tracks through GStreamer rather than a mocked player. A broader codec matrix is opt-in.

Isolated state

Tests and visual checks never touch real user data. Point apps at temporary directories through their isolation variables (for example ENZ_PHOTOS_LIBRARY and ENZ_PHOTOS_STATE in Photos,) and use private XDG_* directories.

Lints in tests

Production code keeps a strict lint policy. A clippy.toml relaxes it for tests only:

toml
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-print-in-tests = true
allow-dbg-in-tests = true
allow-panic-in-tests = true

Where tests live

Small unit tests sit beside the module they test, or in its tests.rs child. Render-level suites are grouped under a module such as src/render_tests/. Integration tests in tests/ are used only where an honest public boundary exists; most apps are binary-only. Test files are named after behaviour, never after issue numbers.

Positive controls

A passing test proves little if it would also pass when the code were broken. Some apps record sabotage records in sabotage.toml at the app root: an exact source edit that should break a named test, and the failure message expected.

toml
[[sabotage]]
id = "first-frame-seed-1400-overrides-phone-rung"
file = "src/app.rs"
test = "app::first_frame_gate::first_frame_at_phone_width_shows_no_inline_sidebar"
find = '''            window_width: 0.0,'''
replace = '''            window_width: 1400.0,'''
expect = "SidebarInline"
# find and replace trimmed for brevity

The checker first confirms the named test passes on clean source and matches exactly one test, then applies the edit, requires the test to fail with the expected message, and restores the original bytes. A test that stays green under sabotage is reported as a dead gate.

Visual checks

Unit tests cannot judge layout. Visual capture in both themes and at four window sizes is covered in Visual capture and review.