FlexUnit test and test suite generators

The Enterprise IDE Plugin supports the generation of FlexUnit tests and test suites. The tests can be generated for a Flex project or for a particular class. When generating tests for a Flex project, each class with source defined in the project (not from a SWC library) will get a corresponding FlexUnit test class.

Each method in the original class will produce a test method as well. Each package in the project will generate a test suite containing all the tests defined for each class in the package. Similarly a project test suite will be generated containing all tests suites and a project test runner will be created.

The source folder for the tests can be selected in the Enterprise IDE preference page. By default the unit tests will be created in the project main source folder if a test source folder is not specified in the preference page.

Note: If a class has an existing test class associated to it a new test class is not generated for it. The tests suites however are always recreated to accommodate all tests, pre-existing and new. The tests methods generated are stubs, they will have to be filled with the actual testing code.

Usage

Select Enterprise IDE > Generate FlexUnit Tests in the top menu. If a Flex project is not active a Flex project selection dialog will be displayed. Then a project class selection dialog will appear. The class selection dialog shows a checkbox tree with entries for all source folders and classes in the project. After clicking "Finish" the tests for the selected classes, test suites and test runner will be generated for the project.

Note: Consider using the Flex Metrics Explorer CCN (Cyclomatic complexity) number to decide how many tests are needed for a particular class method.

To generate a FlexUnit test for a single class, use the class context menu on the Flex Package Explorer or Cairngorm Explorer and choose Generate FlexUnit Test, or alternatively right click on the class AS file on the Flex Navigator and choose Enterprise Flex > Generate FlexUnit Test for AS Class.

Note: The Flex project needs to have the flexunit.swc library on the build path for the tests to be generated properly.