Generate Random Name PDF Print E-mail

Technique Description

Static data entry is constrained by the fact that it doesn’t allow the automated scripts to automatically adjust with the dynamic applications. An advantage of inputting random data is an increased robustness of the scripts that more gracefully handle application changes. Another advantage is in the fact that over multiple automated test executions, test coverage is increased since different data may be entered in each run. This particular technique focuses on generating a random name from an array of known names (note: you may choose to store the list of known names in a database table or spreadsheet, but the example uses an array within the script). This random name may then be entered into an application under test.

The process for inputting random data into an application is as follows:

  1. Obtain a collection/array of objects or data elements from which one random object will be selected.
  2. Get a count of the total number of items in the collection/array.
  3. Use random number generator to select a random element from the collection/array.

 

Downloadable Functions

This section provides samples of the above technique in various scripting languages. Note that many automated test tools (commercial and open source) use industry standard scripting languages, therefore the code can be used in a standalone manner as well as in various tools (i.e. VBScript code can be used in QTP, and Ruby code can be used in WATIR).

 

 The below links provide the code in .txt files. Download then change the extension appropriately.

 

Helpful External Links