#gui-widgets #widgets #graphics

iced_test

A library for testing iced applications in headless mode

2 unstable releases

Uses new Rust 2024

0.14.0 Dec 7, 2025
0.0.0 Dec 3, 2024

#1041 in GUI

Download history 60/week @ 2025-11-26 15/week @ 2025-12-03 18/week @ 2025-12-10 9/week @ 2025-12-17 226/week @ 2025-12-24 153/week @ 2025-12-31 17/week @ 2026-01-07 18/week @ 2026-01-14 76/week @ 2026-01-21 162/week @ 2026-01-28 284/week @ 2026-02-04 240/week @ 2026-02-11 214/week @ 2026-02-18 348/week @ 2026-02-25 364/week @ 2026-03-04

1,240 downloads per month
Used in 5 crates (4 directly)

MIT license

265KB
5.5K SLoC

Test your iced applications in headless mode.

Basic Usage

Let's assume we want to test the classical counter interface.

First, we will want to create a Simulator of our interface:

use iced_test::simulator;

let mut counter = Counter { value: 0 };
let mut ui = simulator(counter.view());

Now we can simulate a user interacting with our interface. Let's use Simulator::click to click the counter buttons:

#
#
let _ = ui.click("+");
let _ = ui.click("+");
let _ = ui.click("-");

Simulator::click takes a type implementing the Selector trait. A Selector describes a way to query the widgets of an interface. In this case, we leverage the Selector implementation of &str, which selects a widget by the text it contains.

We can now process any messages produced by these interactions and then assert that the final value of our counter is indeed 1!

#
#
#
for message in ui.into_messages() {
    counter.update(message);
}

assert_eq!(counter.value, 1);

We can even rebuild the interface to make sure the counter displays the proper value with Simulator::find:

#
let mut ui = simulator(counter.view());

assert!(ui.find("1").is_ok(), "Counter should display 1!");

And that's it! That's the gist of testing iced applications!

Simulator contains additional operations you can use to simulate more interactions—like tap_key or typewrite—and even perform snapshot testing!

Dependencies

~27MB
~556K SLoC