-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headless Mode Testing #2698
Merged
Merged
Headless Mode Testing #2698
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Font selection is platform-dependent.
This is a remarkable milestone for Iced. GG Héctor 🙌 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a brand new crate for headless mode testing:
iced_test
.This crate features a
Simulator
type that can be used to simulate user interactions and query anyElement
produced byiced
.Basic Usage
Let's assume we want to test the classical counter interface.
First, we will want to create a
Simulator
of our interface:Now we can simulate a user interacting with our interface. Let's use
Simulator::click
to click the counter buttons:Simulator::click
takes aSelector
. ASelector
describes a way to query the widgets of an interface. In this case,selector::text
lets us select 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
!We can even rebuild the interface to make sure the counter displays the proper value with
Simulator::find
:And that's it! That's the gist of testing
iced
applications!Simulator
contains additional operations you can use to simulate more interactions—liketap_key
ortypewrite
—and even perform snapshot testing!