Conversation
Co-authored-by: ShootingStarDragons <ShootingStarDragons@protonmail.com>
Contributor
|
I have some thing about the settings... sometime I want to use the special setting for some special platform, but in this pr, the settings is fixed. So can it become a generic type? Ok, I think I can ignore it. no mind |
This file contains hidden or 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
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 implements the foundations of a first-class end-to-end testing toolkit compatible with any
icedapplication.The Test Recorder
The most important new tool of this update is the tester (or test recorder).
The tester can be enabled through the new
testerfeature flag. When enabled, youricedapplication will be decorated with an interface that allows you to both record and play tests as well as export and import them as files.iced-tester.mp4
The long term goal of this tool is to be a fully-featured testing suite for QA engineers to create tests that emulate user interactions as well as define assertions and expectations about a user interface.
The Emulator
Once end-to-end tests have been recorded and saved, we need a way to run them—ideally in a completely headless environment.
The new
Emulatortype implements a headless runtime where test instructions can be executed.Unlike the existing
Simulatortype, anEmulatordoes execute tasks and subscriptions and, therefore, side effects will be materialized. It's as close to running the real thing as possible!An
Emulatorcan be configured with different modes, which change the waiting strategy before proceeding to the next instruction.You should rarely have to use this type directly. Instead, users are expected to leverage the new
iced_test::runfunction to run an entire directory of tests for their applications:Program Presets
In order to be useful, end-to-end tests must be reproducible.
This can be a challenge, since executing them often produces side effects that change external state. When done naively, these side effects can affect next executions of the test; losing reproducibility in the process.
To mitigate this, an
icedapplication can now define a list of presets. APresetsimply describes a certain way to create the initial state of an application.Tests can then reference a particular preset, which can be leveraged to ensure an application is exactly in a reproducible state before the test is executed.
For instance, the
todosexample defines a couple of presets:Ice Test Syntax
End-to-end tests that have been exported are saved as text files using a new custom syntax.
These test files are expected to have the
.iceextension and, as a result, we call these tests "ice tests" or simply "ice". I think the name works well not only because the library is namediced, but also because end-to-end tests are meant to "freeze" the behavior of an application completely in time.The details of the syntax are very likely to change in the near future and, therefore, relying to much on this new feature is not encouraged yet! The changes here simply set up the first foundations for all of the testing infrastructure.
In any case, if you are curious, here is what the current
carl_sagan.icetest looks like for thetodosexample, which is already running as part of our CI pipeline:As you can see, there is a bit of metadata at the beginning—stating the environment of the test—followed by the list of test instructions.
The syntax is meant to be easy to read and write. In the long run, I'd like for QA engineers to be able to write tests from scratch without necessarily using the recorder.
The
SelectorAPIIn order to implement these tools, I have formalized the old
SelectorAPI iniced_testand moved it into its own subcrate:iced_selector.This new
SelectorAPI can be leveraged to easily traverse the widget tree and extract any data from it:This trait is implemented for
String,&str,widget::Id, and anyFnMut(Candidate<_>) -> Option<T>.When the
selectorfeature flag is enabled, the API can be leveraged through thewidget::selectormodule:And that should be all! I don't expect these features to be quite useful right away. I am just planting the seeds for now.