Sometimes you cannot use existing data and you have to generate new data. The generation module now supports generating new rows inside existing tables.
The Generation section allows the user to create and configure different generations sets that generate new data. A generation set is a specific set of tables that can be configured to generate data that covers specific test data requirements. For example; 10 female customers between the age range 45 - 65, with specific contracts on specific products.
When executed, each generation set will generate its rows into a temporary table. After all temporary tables of the generators sets are filled, the data will be inserted into the original table.
To add a new generation set, click the Add generaton set button in the toolbar. This will create an empty generation set. You can change the name and add a functional description.
After adding a generation set, you can specify which tables you want to configure. You can expand the tree view to see which tables are part of the generation set.
To specify how many rows you want to generate, select the specific table and change the Rows value. By default there will be 100 rows generated. You can also specify if the table should be truncated. Please note that when you generate data for the same table in different generation sets, you should uncheck the Truncate checkbox.
When selecting a column, you can specify which generator must be used to fill the column. Use the drop down and select one of the many generators available. Depending of the chosen generators, you often have to specify generator specific parameters.
Below the generator properties, the Null values % slider determines roughly how many NULL values must be generated. This is not exact, only for 0 and 100.
When a column is mandatory or is part of the primary key, a warning icon is shown when there isn't a generator is selected. The the Null values % slider is not disabled on mandatory or primary key columns, however be aware that generating null values for mandatory / primary key columns could mean that the specific constraints will not validate durng the enablement stage after the generation operation.
Cloning generators sets and copying generator specifications
Specifying different generators on a lot of columns and tables can be time consuming. Luckily you can easily clone generation sets that you can than change for a different purpose. Select the generation set and click the Clone generation set button. Each table and their generator properties are copied to the cloned generator set. Make sure to update the primary key columns to prevent duplicate keys.
There is also an option to copy the generator specification of a table or column and paste it in a different generator set. Right click a table or column and select Copy generator specification, then right click a target table or column and click Paste generator specification. If you copy the complete generator specification of a table, the table on which you can paste it should contain the exact same columns. Otherwise the paste option is greyed out.
The SQL expression generator is special in that it can use values from other columns. All other generators will generate it's values into a temporary table per generation set inside your database. The SQL expression on a column is used when the data in inserted back into the original table. That way a user can use the data that is generated in other columns. No dependency specification os required since SQL Expression rules will be the last to be applied to the table in focus.
There are different methods to fill foreign key values! You can choose a constant if you want to refer to a specific value in the parent table. In that case you have to make sure that the referring key is present in that table. The Foreign Key generator however uses a lookup to actually get values from the parent table. There might be two cases;
- The parent table is part of the same generation set; in this case keys are generated that refer to the new parent records generated in the same generation set
- The parent table is not part of the same generation set; in this case keys will be generated using current data content in the parent table