The Banking Demo provides a real-world example of how GenRocket can be used to quickly generate custom synthetic test data and populate database tables to meet specific testing needs. In this solutions article, we're going to quickly and easily solve some test data challenges using GenRocket Test Data Cases on a simulated bank database.
It is extremely difficult to create test data for testing a complex relational data model using spreadsheets, which is why testers often attempt to use production data; but, production data is insecure and also unpredictable when trying to solve a particular test data challenge. But, with GenRocket's synthetically generated test data combined with GenRocket's Test Data Cases, you can quickly and easily overcome these test data challenges.
A few steps are necessary before you will be able to complete this demo:
- You will need to install MySQL on your system. A PDF document has been provided at the bottom of this article for installing MySQL on a Windows machine.
- Create a Database with a name bank_demo.
- Import the database dump to create tables using the attached bank_demo.sql file. Follow steps provided here to import the database dump.
- You need a JDBC configuration (e.g config.properties) file that has the database connection-related information like URL, driver, user, password, etc.
Example JDBC Configuration File
Below is an example of a JDBC configuration file defined to connect to a MySQL database called bank_demo.
Note: The config.properties file attached to this article can be used for the Banking Demo. Make certain to change the password within the file.
This file will need to be stored on your local machine. The location of the file will need to be the referenced value for the database resource in the GenRocket web platform.
Note: For more information, please see this knowledge base article: How do I connect GenRocket Runtime to a Database?
The following attachments have been included at the bottom of this article to help with setting up the Banking Demo:
- How To Install MySQL Sever.pdf - This PDF provides steps for installing MySQL on a Windows 7 machine and can be used to assist with the install on any Windows machine.The steps may vary per operating system version.
- JDBC Configuration File (config.prroperties) - This attachment can be used to set up the required Database Connection Properties File for GenRocket Runtime.
- Database Dump (Bank_Demo.sql) - This attachment will need to be used to perform the database dump, which creates the required Table Schema for the Bank_Demo database.
- ER Diagram (BankDemo ER Diagram.png) - This attachment provides the ER Diagram used for the Banking Demo and shown in the solutions video below.
The following video can be used to learn more about how GenRocket can help better manage test data and overcome your test data challenges:
So, let's take a look at how this can be done.
- Within the GenRocket Web platform, we imported the description of each table within the database and modified a few of the Generators that were auto-assigned to each Attribute, as we have done here, on the customer.
- For some Domains, we also defined their relationships to each other to establish and guarantee referential integrity during test data generation.
- Within GenRocket's self-serve Test Data Cases platform, you can define your own Test Data Case suites and within a suite, define multiple Test Data Categories for your test data cases.
- We have defined a suite called BankingTables and within the suite, we have defined three categories, negative, load, and integration.
Defining GenRocket Test Data Cases
Defining negative cases is easy because you get to control how the negative test data is generated. In this case, we linked four Generators to a Test Data Case Domain to create a negative SSN. The Generators generate the following data:
- gen1 - A valid SSN
- gen2 - Disruptive Characters
- gen3 - Places Disruptive Characters within the SSN
- gen4 - Selects a Negative SSN every fourth iteration
The fourth Generator (gen4) determines if a valid SSN or negative SSN will be used for the data record.
- caseTrue - Negative SSN
- caseFalse - Valid SSN
Note: These Generators are assigned and linked within the Test Data Case Domain for the ssn Attribute. To learn more, please see this knowledge base article: How to Add an Attribute to a Domain at the Test Data Case Level.
GenRocket even provides you with the instructions for executing the Test Data Case on any Scenario. All you need to do is download the Test Data Case Suite and then run it with the Scenario using the provided command line.
Note: To learn more about downloading and running Test Data Cases (TDC's) with Scenarios or Scenario Chains, please see this knowledge base article: How to Download and Run a Test Data Case Set with a Scenario.
Delete All Data from Database
Before we run our first Test Data Case, we want to delete all data from the database to start with a clean slate. Once cleared,
The following data will need to be deleted for the Banking Demo.
delete from card_product;
delete from customer_account;
delete from transaction;
delete from account;
delete from customer;
delete from branch;
delete from account_type;
delete from account_level;
delete from transaction_type;
delete from card_type;
Test 1: Run The Test Data Case with the Customer Scenario
Now we can go to a command line and run our Test Data Case on any Scenario. For this example, we are going to run the Test Data Case on the CustomerScenario, because we only need to populate the customer table with negative test data.
genrocket -tdc BankingTables.gtdc:Negative.badSSNs -r CustomerScenario.grs
And sure enough, we when look at the test data, we have generated 100 customers and every fourth customer has a Negative SSN.
Attaining this negative pattern from production data would be next to impossible. Now, we can empty the database again and move onto our next test.
Sample Output - Customer Table
Test 2: Populate Type Tables
genrocket -tdc BankingTables.gtdc:Integration.typeTables -r TypeTablesScenarioChain.grs
Test 3: Populate the Interrelated Account Table with Specified Amounts of Test Data
So, let's use the smallSetup TDC and also add to it a Test Data Rule (TDR) to control the value of the account balance generated based on the assigned account level.
genrocket -tdc BankingTables.gtdc:Integration.smallSetup -r AccountTablesScenarioChain.grs