What most users overlook from what I can see on forums and written articles is on the subject of unit testing functions that produce inherently non-concrete returns. For example, how would one go about unit testing a function that generates random numbers? It would be futile to try to only gaged a single outcome of the function as there is no way to anticipate what the return would be. However, this is where pattern matching comes into play. If the function is designed to generate numbers 1-100, run the function 100,000+ times and analyze the results. Did the function return a number higher or lower than 1-100? Did the function return a unique number way more times than randomly likely (for example, the number “20″ was returned 50,000 times)? Was a non-number or decimal number returned? Did each call to the function become progressively slower indicating a memory leak?
While this was a simple example, do not be discouraged of making a unit testing against something seemingly chaotic in design. Most things that seem random are usually rather predictable when viewed from a distance.

Link to Flash and Flex Unit Testing package: http://code.google.com/p/as3flexunitlib/

Tags: ,