Adobe Flex 3 Help

Compiling applications for testing

If you do not use run-time testing, you must compile applications that you plan to test with the testing libraries. The functional testing classes are embedded in the application at compile time, and the application typically has no external dependencies for automated testing at run time.

For information about run-time testing, see Use run-time loading.

When you embed functional testing classes in your application SWF file at compile time, you increase the size of the SWF file. If the size of the SWF file is not important, you can use the same SWF file for functional testing and deployment. If the size of the SWF file is important, you typically generate two SWF files: one with functional testing classes embedded and one without.

To compile the Flex application for testing, you must reference the automation.swc and automation_agent.swc files in your include-libraries compiler option. If your application uses charts or the AdvancedDataGrid classes, you must also add the automation_dmv.swc file. You might also be required to add automation tool-specific SWC files; for example, for QTP, you must also add the qtp.swc file to your application's library path. If you are using the AutoQuick example, you must add the AutoQuick.swc file.

By default, Flex Builder includes the automation SWC files in its library path, but you must add these libraries by using the include-libraries compiler option.

When you create the final release version of your Flex application, you recompile the application without the references to these SWC files. For more information about using the automation SWC files, see the Flex Automation Release Notes.

If you do not deploy your application to a server, but instead request it by using the file protocol or run it from within Adobe Flex Builder, you must put the SWF file into the local-trusted sandbox. This requires configuration information that is separate from the SWF file and the wrapper. For more information that is specific to QTP, see Testing Adobe Flex Applications with Mercury QuickTest Professional.

To include the SWC files, you can add them to the compiler's configuration file or as a command-line option. For the SDK, the configuration file is located at sdk_install_dir/frameworks/flex-config.xml. To add the automation.swc and automation_agent.swc libraries, add the following lines to the configuration file:

<include-libraries>
    ...
    <library>/libs/automation.swc</library>
    <library>/libs/automation_agent.swc</library>
</include-libraries>

You must uncomment the include-libraries code block. By default it is commented out in the configuration file.

You can also specify the location of the SWC files when you use the command-line compiler with the include-libraries compiler option. The following example adds automation.swc and automation_agent.swc files to the application:

mxmlc -include-libraries+=../frameworks/libs/automation.swc;
../frameworks/libs/automation_agent.swc MyApp.mxml

Explicitly setting the include-libraries option on the command line overwrites, rather than appends, any existing libraries that you include in the configuration file. As a result, if you add the automation.swc and automation_agent.swc files by using the include-libraries option on the command line, ensure that you use the += operator. This appends rather than overwrites the existing libraries that are included.

To add automated testing support to a Flex Builder project, you also add the SWC files to the include-libraries compiler option.

Add SWC files to Flex Builder projects

  1. In Flex Builder, select your Flex project in the Navigator.
  2. Select Project > Properties. The Properties dialog box appears.
  3. Select Flex Compiler in the tree to the left. The Flex Compiler properties panel appears.
  4. In the "Additional compiler arguments" field, enter the following command:
    -include-libraries "sdks\3.0.0\frameworks\libs\automation.swc" "sdks\3.0.0\frameworks\libs\automation_agent.swc"
    
    

    In Flex Builder, the entries in the include-libraries compiler option are relative to the Flex Builder installation directory; the default location of this directory on Windows is C:\Program Files\Adobe\Flex Builder 3.

    If your application uses charts or the AdvancedDataGrid classes, you must also add the automation_dmv.swc file.

  5. Click OK to save your changes.