Manage Test Data


This feature is only available for Java projects with QMetry Automation Framework.

Introduction

The Test Data functionality allows testers to execute same test case multiple times with different data inputs; without having to create duplicate/repeated test cases. It replaces the traditional practice of entering hard-coded input values with parameters. Test Data allows QA teams to store reusable test data in one centralized location and import existing parameters and data sets. Managing test cases with test data is one of the ways to make your tests consistent and manageable. You can create automated data-driven tests quickly using Test Data in QAS.

Example

The following values need to be validated against Username and Password in the Login test case.


UsernamePassword
Davidadmin123!
Lizaadmin123$
Mathewadmin123%


Create Test Data

Users can create the following types of test data to use in test cases:

(A) Internal Test Data

  • CSV
  • SQL
  • Example

(B) External Test Data (CSV/XLS/XLSX)


A. Internal Test Data

A-1. Internal Test Data- CSV

On the lower panel at left, switch to the TestData Resources tree by clicking on the Test Data tab at the bottom.

You can add a new file for test data in the existing folder or you can also add a new folder and then add the test data file in it.



Manage Columns

To add columns for test data, select the file on the tree and click on the Columns tab.



The Manage Columns screen opens with default columns on it.

A. You can edit the default column name. If you do not require the default columns, you can delete them too.

B. To add a new column, enter the new column name.

C. Then click on the Add button to add the column. You can also change the sequence of the columns through the drag & drop operation.

D. Once you are done with adding/editing columns, click on the Apply button at the bottom.


The column headings for the test data file will appear in accordance with what you have saved on the Manage Columns screen.

Add Properties to Columns

Now it's time to add properties to the test data columns.

Click on the Add tab. A blank row is added on the grid.

The cells are editable. Click in the cell and enter the property values.

This way, you can add multiple columns and their properties for a test data.



Import Test Data - CSV/XLS/XLSX

You can import readily available CSV, XLS and XLSX files containing test data in it.

Click on the Import tab.

Select the file path and click on the Import button to initialize the test data import.



Once the file is imported, the test data starts displaying on the screen.



A-2. Internal Test Data - SQL


Users can configure, query and use test data from MySQL & MSSQL database tables. QAS supports Test Data in Java/TestNG, Java/QAF and Java/Cucumber projects to make use of test data in test cases.

Users can connect database for importing test data for execution. The feature lets user use the test data directly from the existing database. Users can also write a query and fetch the required data in QAS. QAS test cases are executed using this test data. The queries in the SQL file are executed and synced with the database each time before test case execution.

QAS supports MySQL and MSSQL databases.


Steps to setup database

Step 1. Click on the Integrations icon on the tree.



The pop-up opens asking for the details.

Enter the following details to establish the Database connection.

  • Select Database Type: MSSQL and MYSQL are supported databases. Select the one that you want to connect with QAS.

  • Hostname

  • Username

  • Port

  • Password

  • Database

Click Save once tested successfully.



Once the database is connected, the file gets saved in the local drive. If the database connection is lost, the test case still gets executed from the test data that is present in the local file.

Step 2. Now create a new file with .sql extension. On the lower panel at left, switch to the TestData Resources tree by clicking on the Test Data tab at the bottom.

You can add a new file for test data in the existing folder or you can also add a new folder and then add the test data file in it.



Step 3. The Add New File pop-up opens.

  • File Type: Select SQL as file type.

  • File Name: Enter the name to save the SQL file with.

Click ADD.



Step 3. SQL editor opens for the file. Write the query in the editor and click Execute it to fetch data from the database.

Note: Users can write only SELECT queries.

Click Save once the data is rendered on the screen.



The file will be added to the project structure. You can view the file on on the Test Data tab on the lower panel at left.

A-3. Internal Test Data - Example

Example Test Data is an internal test data file to make test case data driven. The test data will be attached with test case in same file. 

The advantage of Example data is that there is no need to create extra test data file. Data can be easily edited in the test file.

There are following buttons on the file:

  • Columns: To add a new column for a new variable in the file.
  • Add: To add new test data in the file.
  • Delete: To delete a row in the file.
  • Save & Close: To save and exit the file.



After clicking on the Save & Close button, the following screen opens where users can make the test case data driven by using column names as below.


B. External Test Data - CSV/XLS


User can use test data files of format .csv and .xls stored externally while executing the project. Users can save time instead of creating duplicate test data in QAS.

Users can link external test data file from local system and use it in QAS test cases for execution. The file format can be XLS or CSV.

Step 1. Go to the Test Data tab and select External Test Data.



Step 2. Browse and select the test data file path and click Link.



Use Test Data: CSV/SQL

1. Record a test case

You need to record the first test case to construct a basic format of test steps.

See the Input field of test steps. It contains the actual values you entered while test recording.



2. Apply Test Data

Click on the Test Data tab.

It opens a pop-up to select and import the test data repository file.



Select the CSV/SQL file you want to import and click on the Apply button.



3. Replace Input field values with placeholder

Open the test case recorded in Step 1.

Replace the Input field values on the grid with placeholder in the format as mentioned below.


Syntax of placeholder: ${column_name}


As per the Login example cited in the previous sections, we have multiple combinations of Username and Password in the test data file.

There are two columns in the test data file: Username and Password.

For Command = "Type" and Element name = "username", replace the Input field values with ${Username} placeholder 

For Command = "Type" and Element name = "password", replace the Input field values with ${Password} placeholder 



4. Execute Test Case with Test Data

Execute the test case by clicking on the Execute button.



The test will run multiple iterations in accordance with the properties entered in the test data file.

The test step will be executed for each value of the Input field.

The resultant files will be added as child nodes to the parent test case on the Test Suites tree.



The child nodes of the test case will be added as test steps in QMetry/QTM4J when the  test results will be uploaded.