Moving to the JavaStar Model: Making Tests More Robust


You can make your tests easier to create and maintain by:

Writing Tests Using Declaration Files

Using JavaStar, you can generate declaration files for your application's GUI in a matter of minutes. These files contain the declarations for each GUI component. Once you've created the files, you can record scripts that reference the declaration files.

What this does is provide you with a level of abstraction. You can change the names of the declarations (possibly make them more meaningful for test purposes) and incorporate the new names into the tests you record. If the user interface changes--for example, if a component changes type, name, or position--you can update the declarations file to reflect the change, and your tests will automatically reference the new information.

When you use declaration files, your tests require less direct maintenance, resulting in a significant time savings.

Making Tests Modular

Writing tests as small modules that exercise a specific feature--perhaps a single component--is a lot like creating building blocks. Alone, the scripts don't do much, but when combined with other scripts, you can create many combinations.

In the case of TestNameDB, there are many options for breaking the test down into smaller scripts. As it stands, the test performs the tasks of loading a database, adding a record, and verifying the record through a search mechanism. Each of these tasks is made up of smaller actions, such as entering data or clearing the display. These tasks and actions, when separated into different scripts, create a strong base of re-usable test material.

To take advantage of smaller scripts, JavaStar provides a Test Composer. Using this feature, you can link scripts together, defining the order and test conditions for execution. You can also define certain scripts as restart nodes for error recovery. The files you create in the Test Composer, called JavaStar Test (JST) files can be nested to build more sophisticated test suites.

Passing Data as Arguments

Because you can perform the same test with different data and get different results, it makes sense to keep your tests as independent of the data as possible, and make it easy to change the values you feed them. With JavaStar, you can do this easily by replacing data in the scripts with references to arguments, then passing the data to a script using the parameter feature of the Test Composer. The source of the parameter can be a parameter passed into the JST, a constant defined in the JST, or a value read from a property file.

Using arguments is an important part of making re-usable test modules.




Send feedback to JavaStar-feedback@suntest.com
Copyright © 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303. All rights reserved.