Use test data in test cases

Test data in Tosca Cloud helps you build a broad range of test scenarios in less time. This topic explains how to link your test data to your tests. It also has information on how to reuse test data and how to update test data during test runs.

Before you start

Before you can start using test data in a test case, you need to have the following things:

  • A test case with a designed test sequence. You'll link your test data to specific test actions, so you can't link to an empty test case.

  • At least one data set in Tosca Cloud. You can also link to subsets, so if that's your plan, have your subsets ready.

Note that by default, Tosca Cloud supports one row of data from the same data source per test case. However, there are options if you want to use multiple rows in the same test case.

Reference your test data

To use test data, you need to reference it in the value column:

  • If your data set or subset belongs to the workspace, use the syntax {TDM[<name of data set>][<name of subset>][<name of column>]}. You can leave out the subset parameter if you don't specify a subset.

  • If your data set or subset is a shared asset that belongs to an asset library, use the syntax {TDM[<name of the library>][<name of data set>][<name of subset>][<name of column>]}. With this syntax, you must enter empty brackets if you don't specify a subset.

    Alternatively, use the parameter named TestDataWorkspace and the syntax {TDM[<name of data set>][<name of subset>][<name of column>]}. With the parameter, you maintain the library name in a central location and don't have to type it into multiple test steps. And if the library changes, you only need to update the parameter value.

Reference test data that belongs to the workspace.

  • With {TDM[Cars][Mercedes][ManufactureDate]}, you use data from a column called ManufactureDate. This column is in the subset Mercedes, which is a subset of the data set Cars.

  • With {TDM[Contacts][LastName]}, you use data from a column called LastName. This column is in the data set called Contacts.

Reference test data that's a shared asset. In this example, you don't use the parameter TestDataWorkspace, which means you need to define the library name in the expressions.

  • With {TDM[Main data][Jewelry][][Type]}, you use data from a workspace called Main data, from the data set Jewelry. You want to use the data that's in the column Type.

  • With {TDM[TeamLibrary][Clothes][Jeans][Color]}, you use data from a workspace called TeamLibrary. This data is in the subset Jeans, which is a subset of the data set Clothes. You want to use the data that's in the column Color.

Use multiple data rows in the same test case

By default, you can use one row from the same data source within one test case. If you have a large data set and want to use multiple rows in the same test case, choose one of the following options:

  • Create subsets. Tosca Cloud uses one row per subset in the same test case.

  • Use the standard module called Test data - Find and provide item. With this module, you define conditions the data must meet. At runtime, Tosca Cloud returns all matching rows and stores the first one under an alias of your choice. To use the alias data, simply reference the alias in a test step.

    You can add the module as many times as you like to define multiple rows of data in the same test case.

Reuse test data

Each time you run a test case, Tosca Cloud consumes the data and marks the row as used. This is true for both types of test runs: trial runs and actual test runs.  

By default, Tosca Cloud blocks rows from being used more than once.

  • If the row comes from a subset, Tosca Cloud blocks the row in the subset and in the parent data set.

  • If the row comes from a data set that has subsets, Tosca Cloud blocks the row in the data set and all its subsets.

You can see the status of your test data on the Test data page.

If you want to reuse a row in future test runs, choose one of the following options:

  • Reset the status manually after the test run. This is useful if you're still in the debugging phase and mostly working with trial runs.

    To manually reset, right-click the status of a row and select Reuse data from the context menu. You can also use the checkboxes to select more than one row at a time.

  • Stop rows from being marked as used in the first place. This is our recommended option for production, because it keeps post-run maintenance to a minimum.

    To stop rows from being marked, use the standard module called Test data - Update item in your test case.

Update data during test runs

You can edit data sets and edit subsets directly from the Test data page, at any point.

In some cases, you may want to edit the row you're consuming during a test run. For example:

  • If you want to reuse the row, but with a different value in the defined column.

  • If you want to keep a permanent record of an outcome, such as an order number, by writing it directly to your test data.

To edit data during a test run, use the standard module named Test data - Update item in your test case.

What's next

You've just linked your test data to your test case. Well done!

Next up: do a test case trial run. Trial runs help you find and fix issues, so you can make your tests as stable and reliable as possible.