Creating Testable Flex Applications

As a Flex developer, you can employ techniques to make Flex applications as "test friendly" as possible. These include:

Providing Meaningful Identification of Objects

To create "test friendly" applications, ensure that objects are identifiable in scripts. You can set the value of the ID property for all controls that are tested, and ensure that you use a meaningful string for that ID property.

To provide meaningful identification of objects:

  • Give all testable MXML components an ID to ensure that the test script has a unique identifier to use when referring to that Flex control.
  • Make these identifiers as human-readable as possible to make it easier for the user to identify that object in the testing script. For example, set the id property of a Panel container inside a TabNavigator to submit_panel rather than panel1 or p1.

When working with Silk Test Workbench, an object is automatically given a name depending on certain tags, for instance, id, childIndex. If there is no value for the id property, Silk Test Workbench uses other properties, such as the childIndex property. Assigning a value to the id property makes the testing scripts easier to read.

Avoiding Duplication of Objects

Automation agents rely on the fact that some properties of object instances will not be changed during run time. If you change the Flex component property that is used by Silk Test Workbench as the object name at run time, unexpected results can occur. For example, if you create a Button control without an automationName property, and you do not initially set the value of its label property, and then later set the value of the label property, problems might occur. In this case, Silk Test Workbench uses the value of the label property of Button controls to identify an object if the automationName property is not set. If you later set the value of the label property, or change the value of an existing label, Silk Test Workbench identifies the object as a new object and does not reference the existing object.

To avoid duplicating objects:

  • Understand what properties are used to identify objects in the agent and avoid changing those properties at run time.
  • Set unique, human-readable id or automationName properties for all objects that are included in the recorded script.