EarlGrey offers features that make testing your app easier and more effective.
Typically, you shouldn’t be concerned about synchronization as EarlGrey automatically synchronizes with the UI, network requests, main Dispatch Queue, and the main NSOperationQueue. To support cases where you want to wait for some event to occur before the next UI interaction happens, EarlGrey provides Synchronization APIs that allow you to control EarlGrey's synchronization behavior. You can use these APIs to increase the stability of your tests. EarlGrey current synchronizes with the following:
|Main Dispatch Queues|
|View Controller Appearance / Disappearance|
|Main Run Loop|
EarlGrey's synchronization works by tracking the states of different resources that can affect the
app's state and performing an action or an assertion only when the app is found to be idle. Based
on the structure of the app, this can affect the performance of the app when tested. EarlGrey
GREYConfiguration values for mitigating these effects, such as changing the
maximum animation duration with
kGREYConfigKeyCALayerMaxAnimationDuration, blacklisting long
network calls with kGREYConfigKeyURLBlacklistRegex or so.
EarlGrey uses screenshot differential comparison (also known as 'screenshot diffs') to determine the visibility of UI elements before interacting with them. As a result, you can be certain that a user can see and interact with the UI that EarlGrey interacts with.
Note: Out-of-process (i.e. system generated) alert views and other modal dialogs that obscure the UI can interfere with this process.
Taps and swipes are performed using app-level touch events, instead of using element-level event handlers. Before every UI interaction, EarlGrey asserts that the elements being interacted with are actually visible (see Visibility Checks) and not just present in the view hierarchy. EarlGrey's UI interactions simulate how a real user would interact with your app's UI, and help you to find and fix the same bugs that users would encounter in your app.