How FlexUnit 4 handles asynchronous actions

Tokens

To handle the asynchronous nature of testing, FlexUnit4 uses a concept called the AsyncTestToken.

A token is simply a small object that is passed around in the testing system. It is much like a baton in a relay race, or an even closer analog would be the ticket given to you by a dry cleaner. Object A passes a token to Object B when Object B has work to do. Object B may then pass another, usually unrelated, token to Object C. When Object C is done with it's work, it notifies Object B by calling a method on the token. Object B may then decide to pass the token to another object if necessary, or if its complete, pass its token back to Object A and so on and so forth.

Having tokens allows every operation and every runner to be potentially asynchronous. It also keeps very recursive items decoupled, since each object has a reference back to it's parent.

Tokens also allow recursive operations to continue over the course of several frames if it is needed.

Having tokens work like this also has implications for future support of multiple security domains.

For more information on tokens, see Sequences.


Back | Decorators

  • No labels