We finally integrated the long-awaited Unit Testing with Flex Unit 4.1. Here’s a little overview about this new feature.

Please Note: Current we only support Flex Unit 4.1 which you can find here (Please choose the full project download).

At the New FDT Project wizard, you can activate this check box, if you like to automatically add test libraries for a new project:

Here you can see the different Flex Unit 4.1 libraries within a project folder:

You can write a test class and you see, that you need to import Assert from a Flex Unit library. The metadata-tag [Test] commands Flex Unit to test the next function.

Now you need to create a test class, here you have to make sure, that you import the Assert Class from the Flex Unit library. Also make sure to mark each test function with a metadata test.

This is the menu path, that you could use to start a test run of class “UnitTest1” (It creates the standard test launch configuration and starts it):

Here you can see details of the launch configuration. You can adjust them for your personal needs, for example you can choose different Test Runner (Sprite, Mxml, Spark) with Sprite being the standard:

You can see the results of your test with the help of the Flex Unit view (bottom right). One test failed and other one was OK. At the External SWF Viewer window, you can see the Flash Player has run with their respective log messages:

If you double click on the first line of Failure Trace, right in Flex Unit view, it will show the Result Comparison window: