UI How to Configure a Database Test Data Query (or G-Query)

In this lesson, you will learn how to complete a Database Test Data Query configuration for the G-Query that was created in the previous lesson.

How do you configure Database Queries?

  1. Create a Database Test Data Query (Query Before or Query Each)
  2. Configure the Query Parameters
  3. Enter the Database Query
  4. Add Domains and Attributes for the Real Data to Populate

2 Types of Database Queries

  • Query Before – Query columns from one or more database tables as a set of data that is buffered into memory.
  • Query Each – Query one row of columns, from one or more database tables, on each row iteration of test data generation.

Database Query Configuration Components

A Test Data Query configuration has the following primary components: 

  • Parameters – Define the resource path, subdirectory, name, and variables for the Test Data Query.
  • Query – Defines the actual query to be performed on the database.
  • Domain Attributes – Defines the Attributes that will be populated by the real data obtained from the SQL query.

Prerequisites: Database Connection Properties File

config.properties file must be available on your local computer to connect to the database and perform the query. The properties file contains the database connection information, and its location should match the defined resource path in the Query Parameters.

Here is an example:

How to Configure a Database Query

For this query, we will be querying the Address Table within a Database and using this information for the following Domain Attributes:

  • address1
  • city
  • street
  • zipCode

Here is a sample of the data that we will be querying from the Address Table:

Step 1: Configure the Query Parameters

For this example, we will be configuring the following Parameters:

  • resourcePath* – Defines the path where the resource file for JDBC connection properties exists.
  • resourceSubDir – Defines an optional subdirectory under the resourcePath where the resource file for JDBC connection properties exists.
  • resourceName* – Defines the name of the resource that contains the database connection information on a user’s local machine.

You can click on a field to enter a value or double click to add a reference. Click the Save button once finished.

Note: Parameters displayed within the Parameters Pane will vary per Query Type.

Step 2: Enter a Database Query

Next, you will need to enter a Database Query. For this example, we will be entering:

select street, city, address, and zip_code

from address

Click the Save button after entering the Database Query.

Step 3: Add Domains and Attributes

Next, you will need to add each Domain and Attribute. These steps will need to be completed for each column that is being queried within the Database.

Click on the Add button to add a Domain and Attribute.

Select a Domain and Attribute within the dialog window.

Enter the Column Name as it is within the database that is being queried. Click the Save button once finished.

Below is the completed configuration for the first Domain and Attribute:

Here is the completed configuration for each Domain and Attribute:

Click on the Column Check button to perform a column check validation for the added Domains and Attributes.

If everything has been configured correctly for the Domains and Attributes, you will see the following message. Click OK.

Completed Database Test Data Query Configuration

Once a G-Query has been created, you can download the Query and run it with a downloaded Scenario, Scenario Chain, or Scenario Chain Set.

The command line is provided at the bottom of the G-Queries Management Dashboard for the selected G-Query.

To run the command, paste it into a Command Prompt or Terminal Window and then replace with the actual name of the Scenario, Scenario Chain, or Scenario Chain Set.

Note: G-Queries can also be added to an individual Test Data Case or G-Case. We will show how to add a G-Query to a G-Case in lesson 5 of this training module.

Generated Data for the Address Domain

For this example, we will show the output as a delimited file.

If you compare the above output with the database records, you will see they are identical:

In the next lesson within this module, we will show how to configure a CSV File Test Data Query.

Links:

https://genrocket.freshdesk.com/support/solutions/articles/19000060937

https://genrocket.freshdesk.com/a/solutions/articles/19000104919

Related Assets

GenRocket - Test Data Management

Download Literature

View Literature
GenRocket - Test Data Management

How to add a Test Data Query to a Project Version

A Project or Project Version may have multiple Test Data Queries.

Read More
GenRocket - Test Data Management

How can we help
you today?