Test Data Management: an Example

Test data management serves to manage, use and reuse test data. In addition, a TQL syntax can be used to search for appropriate objects in the test data repository. The example below describes the basic procedures of test data management.

For a more detailed description on various functions, please refer to the chapter "Manage test data" and "Test Data Management in TestCase-Design".

Importing modules

Before you begin, make sure you have fulfilled the following prerequisites:

  • Test data management is enabled

  • The TDM property is set for all objects relevant to the test data repository

To be able to work with test data management, the required modules need to be downloaded from the Tosca Exchange Portal and imported as a subset into the Tosca Commanderâ„¢ workspace.

Importing Modules

Creating a test data repository

Test data repositories are created by using the Tosca TestCase-Design AddIn.

  • In TestCase-Design you are able to create all attributes to be copied to the test data schema. The property TDM must be selected for the required attributes. In this example, we will first create the ObjectType Customer, which contains the attributes Address and Vehicle including their subordinated attributes, as shown in the illustration below.

TestSheet Customer

  • Next, the test data repository is created by selecting the option Create Schema for TDM from the context menu of a TestCase-Design Sheet.

    In the subsequent dialog you can specify the connection information.

    By default, Tosca displays the connection information to the common repository or to the according TDM repository (see chapter "Create a separate Tricentis Tosca Test Data Management repository").

    In this example, Tosca displays the connection information to the SQLite database named TDM_Sample_tdm.db in the directory C:\Tosca_Projects\Tosca_Workspaces\TDM_Sample\Repository.

    Example: SQLite(C:\Tosca_Projects\Tosca_Workspaces\TDM_Sample\Repository\TDM_Sample_tdm.db)

Connection information

This article uses an SQLite repository since this does not require any preparatory steps. This database type can be used for building test cases. The repository types MS SQL Server, Oracle or DB2 are used in multiuser mode.

Managing test data

The newly created test data repository contains all the required attributes which need to be filled with test data. The ObjectType Customer should additionally be associated with the partner objects Address and Vehicle.

  • The first step is to prepare the test data in an Excel spreadsheet. The test data attributes and their names must match the TestCase-Design attributes.

Test data in Excel

The Excel file, which contains the test data to be used for this example, can be downloaded from the following Tosca Exchange Portal package: Test data management.

  • Now, one by one, mark and copy the ObjectTypes Customer, Address and Vehicle and paste them into the Tosca TDM ObjectEditor by using the option Edit->Paste.

    The Tosca TDM ObjectEditor can be opened by selecting the option Show TDM ObjectEditor from the context menu of the TestCase-Design folder which is linked to the test data repository.

Copying test data

  • The test data need to be explicitly saved via the menu entry Repository->Save.

  • In the next step we will link the object Customer to the classes Address and Vehicle.

    To link objects, four TestSteps are required, which are created from the following Modules:

    Link Customer - Address

    TDM Find Single Object: we will create two TestSteps from this Module. In the first search, we are looking for a customer that is not linked to any address. This is done with the syntax ->All:Customer[COUNT ("Address") == 0]. The second search query produces a random address with a ZIP code between 0 and 9.

The function RND (Random) is used. For further expressions please refer to see chapter "Dynamic expressions"

Linking objects

  • TDM Add Association:in this TestStep the found objects are linked to each other.

    TDM Save: this TestStep saves the object links.

    Link Customer - Vehicle

    TDM Find Single Object: we will create two TestSteps from this Module. In the first search, we are looking for a customer that is not linked to any vehicle by using the following syntax ->All:Customer[COUNT("Vehicle") == 0]. The second search query Vehicle selects a random vehicle with which the customer from the first search query is to be linked. The first found vehicle is always the one that is used.

    TDM Add Association: in this TestStep we will link the found objects to each other.

    TDM Save: this TestStep saves the object links.

  • To make sure that every customer is linked to an address and a vehicle, we have to execute both TestCases 10 times (there are 10 customers available). For this purpose, we switch to the Execution section and we set the value of the property Repetitions to 10 in the ExecutionEntry.

  • The TestCase can now be executed.

TDM ObjectEditor - check data

After the test data repository has been created and test data have been added, we can now open the TDM ObjectEditor to verify that all test data are available and linked.

Show TDM objects

The individual roles are displayed in the right section of the window. The properties of the associated partner objects can be seen via the tooltip.

Associations in the TDM ObjectEditor

Using test data

The HTML sample application will be used to illustrate the use of test data. In this example, the first two pages of the application are to be filled with data from the test data repository.

  • In the first step, we search for customers who are linked to a vehicle.

  • In the next step, we select the vehicle type Automobile in the HTML sample application.

  • In the next step, we navigate to the object Vehicle whose attributes will be used to fill the test application.

  • The test data can be read from the test data repository by using the syntax {TD[Testdata]}.

Using test data

{TD[vehicle.Make]}=={TD[Customer.Vehicle.Make]}

Explanation: In this way, the attributes of the object Vehicle can be retrieved using the association of the partner object.

Checklist

Is test data management enabled?
Is the TDM property set for all objects relevant to the test data repository?
Are all buffer variables correctly formulated? - brackets, spaces, spelling, etc.