Do you still generate testing data manually? So GenRocket comes to you
Tags: bigdata, testing, generators
Published: 2021-01-20 15:54:37

A couple days ago I’ve finally had my [GenRocket](https://www.genrocket.com/) certificate and is going to tell you about this amazing service as a certified specialist! 
But before I’d like to describe the problem that GenRocket helps to resolve. 


##Testing data generation problem
Testing data generation enough for covering minimum possible required scenarios became a big problem for a lot of projects. 
Why is “minimum possible”? Here we can remember “Equivalence partitions”, which refuses testing data from infinity to useful set.
Why is “required”? Here we can remember “Testing coverage”, that tells us testing data have to cover maximum possible scenarios. 
But still taking into account “Equivalence partitions” testing data generation became a challenge for some areas especially for projects are working with data, dig data, data transformation, data processing and etc. Such king of data variations are huge and intermediate results testing reinforce the situation. 

##Ideal testing data generator
Ideal testing data generator has to have opportunity for
•	generate data in different formats (JSON, SQL, XML and etc)
•	generate data with dependencies (parent, child)
•	generate data with complicated depending data (if a then 1 or 2 else 3 or 5)
•	generate data with huge volume in a little time
Nice to have:
•	load data in DB directly
•	integration with CI/CD
•	create data model from schema automatically

##GenRocket university
GenRocket service provides a training-university after accomplishing you will be familiar with base functional, deployment and setting up. 
I strictly recommend graduating this university, the first part is theoretical and a little boring, but you’ll learn all main subjects that service uses. The second part is practical lessons with detailed description where you need to click. This university is appropriate for any level of testers, business-analytics and developers. 

##GenRocket service
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/le3ck95m54tca8vd7cc1.png)
GenRocket  is a service for easy generation of realistic, random, patterned and conditioned test data for any data model. In 2011 Hycel Taylor met and partnered with Garth Rose to package the technology into what is now known as GenRocket. In 2012 they incorporated GenRocket and won their first customers. This service allow to generate data for automation testing, performance testing, security testing and etc. 
The service consists from two part: a web-part and cli-application. The web-part is responsible for creating of scenarios for data generation. The cli-application generates data on the space where was installed. 
Before GenRocket data generation user have to be authorized in web-part. Then a Runtime* archive have to be download from web-part, unpacked in genrocket directory. The path to genrocket directory have to be set up to system environments in **GEN_ROCKET_HOME** and **%GEN_ROCKET_HOME%\bin** value have to be set up in **PATH** variable.
After all these manipulations we should open command line, type genrocket and we’ll see the picture bellow. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/14djndvt9iheu5fjoxem.png)
GenRocket cli-application has two mode on-line and off-line but the GenRocket certificate is necessary for off-line. Unfortunately, GenRocket certificate is valid only 24 hours. 

##GenRocket  domen and attributes 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hxwdiwpptd3gkcpkb3ec.png)
The first two main components are a Domen and Attributes. A domen is a noun, for example: user, address, credit card and etc.  And attributes describe a domen, for example, user domen should contains such attributes: first name, last name, e-mail, birthday, password. You can see on the picture bellow user domen (1) described using attributes (2) and the example of generated data (3). 
It’s possible to add attributes manually (2), with scratch pad or with DDL, CSV, JSON or other formats importing. If we are speaking about data in table view that means domain is a table and attributes are columns.  

##GenRocket generator 
Next component is a generator. The generators create data in different formats like JSON, XML and etc. GenRocket has 150+ generators. For example,   
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dvgnzic0qonvsmjsdmga.png)
GenRocket based on attribute name assesses special generator for each attribute. For example, an attribute with Name word will have NameGen generator and an attribute with SSN word will have SSNGen generator. 
Also it’s possible to set up specific project parameters in generator setting: 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sc9kwotl4n4lv2ytv2nf.png)

##GenRocket receiver
Next component is a receiver. The receivers are responsible for data downloading in necessary formats: XML, JSON, SQL, CSV, JDBC, REST, SOAP. GenRocket has 35+ receiver types. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fksr8k70655wu9mf2ahb.png)
Also, any DB can be a receiver but you have to set up a JDBC connection using special properties files for that. 


##GenRocket scenarios
Next component is a scenario. The scenarios are the sets of instructions which how much and what order the data will be created. There are a single scenario (1) and a chain-scenario (2) which allow to generate data for some linked scenarios in the same time. The loopCount variable from domen setting contains the amount of data. Each domain has their own loopCount variable that allow to generate different amount of data for each domain using the scenario-chain. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dzpvoe8ij2w7mgiajakc.png)
Scenario is downloaded in grs format (3) and have to be executed on the machine where GenRocket runtime had been installed. Then command line should be opened, and the scenario should be executed using genrocket -r UserInsertScenario.grs command.
And after execution the results will contain execution time like you can see on the picture below. 10 thousand records were inserted in BD during 26 sec. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3utqxgrwg4msgovfdi0s.png)

##Using GenRocket on real project 
We have a little data schema contains user, grant_history and notification_setting tables.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rvasipa3yhrhp6szwi7a.png)
Than the user domen was created using ddl import. 
`create table `user` (
  id              int(10) not null auto_increment, 
  external_id     varchar(50) not null unique, 
  first_name      varchar(25) not null, 
  last_name       varchar(25) not null, 
  middle_initial  char(1), 
  username        varchar(100) not null, 
  ssn             varchar(15) not null, 
  password        varchar(255) not null, 
  activation_date date, 
  primary key (id));`
GenRocket assesses appropriate generator for each attribute based on the attribute name. If it’s necessary we can set up specific generator or adjust current. For example, the generationType value is changed on the random and save it. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y0lne3gm4udhto2vhahp.png)
The same actions for grant_history and  notification_setting tables. 
Generated data will be saved in DB using JDBC connection was set up from properties file. 
`driver=org.h2.Driver
user=sa
password=sa
url=jdbc:h2:file:~/lms_course/lms_alpha;AUTO_SERVER=TRUE;
batchCount=1000`
And specific receivers have to be set up for the DB that’s used like  **H2InsertV2Receiver** for insert and  **SQLUpdateV2Receiver** for modification.
After all this manipulation with settings we have two scenario files **InsertScenarioChain.grs** for insert and **UpdateScenarioChain.grs** for modification, then we execute these scenario files and have the picture below. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/n9z8ijfvitj7efu4ofck.png)
So, vuala, data is in tables: 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x0eopnbd8mc2n35v3soq.png)

##Summary
I conducted researches of data generation tool markets and would like to tell that there are two common variants of this services
•	free service with limited functionality of data generation for uncomplicated date models 
•	paid service with unlimited functionality of data generation for any date models providing some free limited functional 

If you have a short-term project with simple data model it’ll be possible to use free services or create an own generator. But if the project is long-term and has complicated data model changing and expanding during all project time the idea of buying paid service becomes attractive and attractive. But that is your choice. 
Bellow you can find the GenRocket prices
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xhy1nvosrqxfuac2wf16.png)

I prepared some links on “free” services for comparison: 
https://www.datprof.com/solutions/test-data-generation/ - only 14 trial days than it will be the asking price 
http://generatedata.com/ - it’s possible to generate only 100 free
https://www.mockaroo.com/ - it’s possible to generate only 1000 free, the rest for charge