How to create an application that can be used to run and graphically view the results of FlexUnit tests.
Create an application that uses a TestSuite instance and TestRunnerBase component to run the tests.
This recipe extends the Create an application that can use the FlexUnit framework recipe.
<?xml version="1.0" encoding="utf-8"?>At this point compile and run the application. The output should look like this:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexui="flexunit.flexui.*">
<flexui:TestRunnerBase id="testRunner" width="100%" height="100%"/>
</mx:Application>
<mx:Script>
<![CDATA[
import flexunit.framework.TestSuite;
private function createTestSuite():TestSuite
{
var testSuite:TestSuite = new TestSuite();
return testSuite;
}
]]>
</mx:Script>
private function handleCreationComplete():voidThis will start the tests automatically after the application has loaded. Add a creationComplete handler to the Application that calls handleCreationComplete():
{
testRunner.test = createTestSuite();
testRunner.startTest();
}
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexui="flexunit.flexui.*" creationComplete="handleCreationComplete();">At this point compile and run the application. The output should look the same as step 1 above.
TestCase instances can now be added to the TestSuite instance and will be run when the application starts. See Adding a TestCase to a TestSuite and Understanding FlexUnit Output recipes.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexui="flexunit.flexui.*" creationComplete="handleCreationComplete();">
<mx:Script>
<![CDATA[
import flexunit.framework.TestSuite;
private function createTestSuite():TestSuite
{
var testSuite:TestSuite = new TestSuite();
return testSuite;
}
private function handleCreationComplete():void
{
testRunner.test = createTestSuite();
testRunner.startTest();
}
]]>
</mx:Script>
<flexui:TestRunnerBase id="testRunner" width="100%" height="100%"/>
</mx:Application>