FlexUnit Setup
Required steps to integrate FlexUnit into a Flex project
Just some reminder notes to set up Flex unit testing. These are valid for FlexUnit 0.9
1. copy the FlexUnit.swc to the projects libs folder
2. Create unit tests
Each Unit test is a simple Actionscript class that extends TestCase
public class MyTest extends TestCase
It contains a number of functions where the function name must start with a test
e.g. testFunc
Each function contains a number of assertions methods.
There are several assertion methods available for our unit tests such as:
assertTrue, assertFalse, assertNull, assertEquals, and several others.
3. Create a new MXML Application
add this mxml tag to the application
<flexunit:TestRunnerBase id=”testRunner” width=”100%” height=”100%” />
add these lines to a creationComplete handler function:
testRunner.test = createSuite();
testRunner.startTest();
add these lines to the createSuite function
var testSuite:TestSuite = new TestSuite();
testSuite.addTestSuite( MyTest );
return testSuite;
all done run the test application and watch it fail