views:

358

answers:

1

I have just tried setup unit testing in Flash Builder 4, and it working nicely. A setup of a parallel test source structure and using Flash Builder 4:s new TestCase and new TestSuite I was up and running with some testcases within minutes.

But now I want to compile them from a ant flex task, the Flash Builder generates FlexUnitApplication.mxml and FlexUnitCompilerApplication.mxml. Is there a nice way to build the unit tests with ant using these? I cant find any sample where this is done.

A: 

We use for each of our test project a CITestRunner.mxml file which essentially contains the following code

<mx:Script>
    <![CDATA[           

        import mx.logging.LogEventLevel;

        import org.flexunit.internals.TextListener;
        import org.flexunit.listeners.CIListener;
        import org.flexunit.runner.FlexUnitCore;

        public function runTests():void
        {
            var core:FlexUnitCore = new FlexUnitCore();
            core.addListener( new CIListener( 40000 ) );
            core.addListener(TextListener.getDefaultTextListener(LogEventLevel.DEBUG));                 
            core.run( new FlexUnitApplication().currentRunTestSuite() );

        }

    ]]>
</mx:Script>

All you need to do is compile the application with this app as main class, and run it using the provided "flexUnit" ant task and you should be just fine.

Axelle Ziegler