What is the quickest way to run my tests and compile my application?

Running FlexUnit tests at times can be very slow. This has little to do with the FlexUnit framework, it is Flash Builder and Eclipse.

Use this method for the quickest workflow:

Make one top level test suite that includes all other test suites. This allows for continual addition over time, but the same suite is always being run. Launch the FlexUnit tests once for that suite, they should run successfully and report their results in the FlexUnit panel.

//SuitesToRun.as

package topLevelSuite
{
    import topLevelSuite.actionscript.ActionScriptSuite;

    [Suite]
    [RunWith("org.flexunit.runners.Suite")]
    public class SuitesToRun {      
        public var flexUnit4ASSuite:ActionScriptSuite;

        /* We have a toggle in the compiler arguments so that we can 
        choose whether or not the flex classes should be compiled into 
        the FlexUnit swc. For ActionScript only projects we do not want 
        to compile the flex classes since it will cause errors. */

        CONFIG::useFlexClasses {
            import compilationSuite.flex.FlexSuite;

            public var flexSuite:FlexSuite;
        }
    }
}

Here is the application that will call the SuitesToRun.as. In Flash Builder Premium, this file is auto-created when you choose to run FlexUnit tests as shown:

runTestsButton.bmp

//Test Application
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" 
               minWidth="955" minHeight="600" xmlns:flexui="flexunit.flexui.*"   
               creationComplete="onCreationComplete()">
    <fx:Script>
        <![CDATA[
            import topLevelSuite.SuitesToRun;

            //Temporary, in order to test the changes made to the suite.
            import tests.flex.lang.reflect.metadata.MetaDataSuite;

            public function currentRunTestSuite():Array
            {
                var testsToRun:Array = new Array();
                testsToRun.push(SuitesToRun);
                return testsToRun;
            }

            private function onCreationComplete():void
            {
                testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), 
                                            "FlexUnit4Test");
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <flexui:FlexUnitTestRunnerUI id="testRunner">
    </flexui:FlexUnitTestRunnerUI>
</s:Application>

Then, instead of closing that browser, keep it open in the background. Don't launch the tests from Flash Builder, instead just compile the application through Flash Builder, switch to the test browser and refresh it. The results will still be sent to Flash Builder, but it should be significantly faster.

Sample FlexUnit Default Browser Window:

unitTestWindow.JPG

In order to run your tests, Flash Builder has to make sure your project is compiled. Anything you can do to make the project compile faster will make the test compilation run faster as well.