When to use Asynchronous Testing

Sometimes when testing you have to wait for a given state before running the test. For example, when you add a TextInput to your application, it is not immediately drawn on the screen, nor is its internal state completely stable. The TextInput, let alone more complicated controls such as ComboBox, go through a complex process before they are ready. This process involves creating children, measurement, and layout, as well as committing any properties to the control that were specified at creation or immediately thereafter. Until this entire process is complete, any tests you write against this component may be invalid. Dependent upon the speed of your machine and other tasks running, each time you run your test the control could be in a slightly different state.

To be consistent with our tests, we need to wait until the control is valid and in a known state before we begin testing against it.

What is Asynchronous Testing

An asynchronous test is one which tests a piece of an application that does not occur at a regular interval. Asynchronous tests are typically tests that are event driven.

Asynchronous Testing Example

See Writing an Async setup for an Asynchronous Testing Example.

  • No labels