DTM File Factory and Template Based Test Data Generation

There are three types of test data files:

  1. Tabular data has a regular structure of rows and columns. DTM Flat File Generator is suitable for this kind of test files generation.
  2. The structured files have structure contains static and changeable content. For example, e-mail message has "from", "to" and "subject" static headers with variable data: names, address or text in the message body.
  3. The non-structured files have changeable content only. The file can have or have not the rule that describes a sequence of variable data items.

In the article, we'll dwell with the second case and with the third case with a repeatable structure of information block.

Let's define "template" as a document that defines a sequence of static content and rules. Each rule describes how the changeable item of the target text should be generated.
There are three types of changeable items:

  1. Randomly generated content.
  2. Optional document's fragment.
  3. Repeatable document's fragment.

Of course, the second and third items can contain static text as well as the first item or items. Let's look at a few examples for each type of item. The first example is a greeting part of the message:

Dear ^^=$Lib(FullNames)^^,

This part of the template contains three items "Dear " text, test data generation engine call ($Lib function) and comma at the end of line.
The second example demonstrates how the optional fragment works:

Technical support^^optional^^ team^^end^^.

This text also has three fragments and adds " team" string between "support" word and the dot sign at the end of the statement. The probability of the "optional" fragment is 50% by default. The NN parameter defines custom probability for the block.

The last example for changeable items is more complex because it contains "repeat" command and two nested data generation engine calls:

^^Repeat 5^^ ^^=$Inc()^^) ^^=A{5:10}^^

The repeat-end block defines that the program should iterate the block five times. $Inc() call with ') ' produces 1), 2), ... 5) elements and A{5:10} generates a random string of upper letters between 5 and 10 symbols, e.g.:


Test File Generation Process

DTM File Factory: output file name macros DATE and TIME

How to use the template-based test file generator in the software development process? Obviously, we have to define the template at the first step. The preview function shows sample template processing result by one click.

Please keep in mind, that you allowed using database data as a source for template filling out. The engine's functions like $Table or $Query were designed for this purpose. We recommend to establish default connection if you decide to use this feature.

The second step is output options definition. By default, only output folder is a mandatory parameter. However, you can manage output file name and even add $DATE$ and $TIME$ macro to the file name pattern. This feature helps to generate the unique set of test files per each execution.

In the last part of our article, we'll build the complete sample. It is a file with the three-level corporate structure: department-manager-employees.

Step 1, general template and department level loop.

Corporate Structure Definition.
^^repeat 5^^
Department '^^=$Lib(Departments)^^'
(we'll place manager definition here at the second step)

Step 2, manager information definition

  Manager: '^^=$Lib(FullNames)^^', Room# ^^=NNNN^^

We added manager's name and four-digits room number.

Step 3, employees with hire date and phone extension

^^repeat 2 to 7^^ -^^=$Lib(FullNames), from $RDate(DD-mon-YYYY,,31-dec-2014), Ext:NNN^^

As you can see, nested ^^= statement contains a few data generation engine calls at once. It is acceptable in most cases. Please refer to engine's manual for details.

There is begin of sample output file:

Department 'Executive'
  Manager: 'Warner Pencak', Room# 6151
   -Katy Yopp, from 14-sep-2011, Ext:725
   -Florencia Myrck, from 05-jan-1985, Ext:620
   -Keneth Nykiel, from 19-dec-2005, Ext:020
   -Warner Feduccia, from 26-aug-1981, Ext:496
   -Tania Mcgranahan, from 29-feb-2002, Ext:951
Department 'Marketing'
  Manager: 'Isreal Millstead', Room# 3762
   -Dell Draa, from 18-nov-2013, Ext:187
   -Cortez Baumkirchne, from 20-mar-1986, Ext:445
   -Erlene Krolick, from 19-jan-2009, Ext:066
Department 'Logistics'
  Manager: 'Hong Neither', Room# 5428
   -Granville Cirioni, from 17-nov-2011, Ext:137
   -Althea Paras, from 01-aug-1977, Ext:089
   -Broderick Derenzis, from 19-nov-2003, Ext:561
   -Arnoldo Linkon, from 19-feb-2001, Ext:425

See Also