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 generates newly data. A generation set is a specific set of tables that can be configured to generate data that cover specific test data requirements. For example; 10 female customers in the age between 45 - 65, with specific contracts on specific products.
When executed; each generation set will generate it's 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.
Too 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 there must 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 of primary key columns, however be aware that generating null values for mandatory / primary key columns could cause that the specific constraints could not be restored after filling the generator.
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 with their generator properties are copied the 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 the fact 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.
There are different methods to fill foreign key values! You can choose a constant if you want to refer to a specific row in a different table. In that case you have to make sure that the referring key is present in the 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 that case only keys are generated that refer to parent records that are generated in the same generation set
- The parent table is not part of the same generation set; in that case keys will be generated that already are present in the target table