Test data modules

Tosca Cloud offers standard modules, which are sets of pre-built test steps for various useful tasks and actions. This topic lists all standard modules for test data:

Test data - Update item

This module allows you to perform the following test data actions:

You can define these actions for one data source at a time. If your test case is linked to multiple data sources, you need to add the module multiple times: once per data source you want to modify.

Tosca Cloud applies the reuse or update action to the row it consumes during the test run, in all linked data sources:

  • If your data source is a subset, Tosca Cloud applies the action to the row in both the subset and its parent data set.

  • If your data source is a data set that has subsets, Tosca Cloud applies the action to the data set and all its subsets.

Limitations

The module doesn't stop Tosca Cloud from marking a row as used if you identify the row with TestData - Find and provide item. However, that's not a problem because TestData - Find and provide item offers its own method to keep a row unused.

Module attributes

When you use the Test data - Update item module in a test case, fill out the following information: 

Attribute

Description

Data set

Name of the data set.

Subset

Name of the subset, if the row comes from a subset.

Reuse data

Specify if you want to reuse a row. To do so, enter True.

Data structure

Define your data update. To do so, perform the following actions:

  • Replace Column with the name of the column you want to modify. Note that this column has to exist in the data set or subset.

  • Enter the new value into the Value column. You can also enter dynamic values, such as date/time expressions or text expressions like buffer.

    If the column already has a value in this row, Tosca Cloud overwrites it.

  • Use action mode Input.

After you've added your information, Tosca Cloud adds a new Column line. To update another column in the same data source, simply fill out the new line.

Defining that you want to reuse data.

This example test case performs the following actions: 

  1. Test step Enter name enters test data into a text box called Name and clicks Next.

    The test data comes from a data set called Customer data, specifically the column Name.

  2. Test step Test data - Update item defines that you want to reuse the row that Tosca Cloud consumes during the test run:

    • Data set with the value Customer data defines where the data is from.

    • Reuse data with the value True indicates that you want to reuse the data.

Screenshot of the example test case in Tosca Cloud.

Click to enlarge: Example test case for reusing data

Updating data during a test run.

In this example, you want to add a time stamp to your data source. To do so, you've added the module to your test case and filled out its values:

  • To specify the location of the data, you've populated Data set and Subset with the respective names: My example data set and Subset A.

  • To define the column where you want to update data, you've replaced Column with the name of the column: Processed.

  • To define the value, you've entered the dynamic date and time expression {DATETIME} into the Value column. At runtime, Tosca Cloud creates a time stamp based on the actual date and time.

Screenshot of the example test case in Tosca Cloud.

Click to enlarge: Using the module to update test data

Test data - Find and provide item

By default, you can use one row of data from the same data source per test case. If you want to use more than one row per test case, the module TestData - Find and provide item is one option you can choose.

With this module, you define conditions the test data must meet. Tosca Cloud picks the first row that matches and gives this row an alias of your choice. To use the test 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.

Limitations

Keep the following limitations in mind:

  • The module only works with data sets. You can't use it to consume multiple rows of a subset.

  • The alias is only valid within the same test case. You can't define an alias in one test case and then reference it in another.

Module attributes

When you use the module TestData - Find and provide item in a test case, fill out the following information: 

Attribute

Description

Data set

Name of the data set.

Alias

Specify a name for the data row that Tosca Cloud will select from all rows that match your query or filter.

The alias is only valid within the same test case.

Query

Enter a query expression that specifies the conditions the test data must meet. Tosca Cloud only returns matching data.

Alternatively, you can define data by Data search filter.

Data search filter

In the Data search filter parameters, specify the column and value that define the data you're looking for. Tosca Cloud will return all rows that have this value in the specified column.

You can enter multiple column-value pairs to fine-tune your filter. Make sure to use the following: 

For the value, you can also use wildcards and regular expressions. Note that Tosca Cloud doesn't support the != operator in regular expressions. You need to incorporate it into the regular expression itself.

Mark data as used

By default, Tosca Cloud marks the alias row as used after you run the test case, whether it's a trial run or an actual test run.

To prevent this so that you can reuse the row later, set the value to False.

Use the module in a test case to create an alias called Audi2020Red.

In this example, you want to filter your data to include only red Audis that were manufactured in 2020. To do so, you add the module to your test case and fill out its values:

  1. To specify the data source, you populate Data set with the name of the data set you want to use in your test case: My example data set.

  2. To define the "name" of the row, you populate Alias with the name you've chosen: Audi2020Red. You'll need this later on, when you want to use the data.

  3. To define the conditions the test data must meet, you use Data search filter. You replace <Column name> with the actual column name and enter the expected value into the Value field. This leaves you with the following parameters:

    • Parameter Brand with the value Audi.

    • Parameter ManufactureDate with the value 2020. Since this value is a number, you select data type Numeric.

    • Parameter Color with the value Red.

  4. To define that you want to reuse the row, you set Mark data as used to False.

Screenshot of the example test case in Tosca Cloud.

Click to enlarge: Module TestData - Find and provide item in a test case

By the way, you can also use Query instead of Data search filter. Simply enter Brand==Audi AND ManufactureDate==2020 AND Color==Red into the Value field of Query.

No matter which option you choose, the result is the same: At runtime, Tosca Cloud returns all matching rows and stores the first one under the alias Audi2020Red.

Define query expressions

The module attribute Query supports the following query components: 

Type

Details

Examples

Values

Strings, numbers, boolean, null

MyString

1467.5 or 1467,5 (depending on the format in your data)

TRUE, FALSE

NULL

Comparison operators

<, <=, >, >=, ==, !=

Status==Registered

Processed!=NULL

Mileage<=10000

Electric==TRUE

Logical operators

NOT (!), AND (&), OR (|)

All cars where the brand is Mercedes or Audi: Brand==Mercedes OR Brand==Audi

All cars where the brand is Mercedes and engine power is equal or bigger than 250: Brand==Mercedes AND Enginepower>=250Mileage

Note that by default, AND and OR are left associate. Use parentheses () to define groupings and set precedence:

  • All cars that are electric, where the brand is either Mercedes or Audi: 

    Electric==TRUE AND (Brand==Mercedes | Brand==Audi)

    This is a good example for setting precedence. AND and OR are left associate, so if you don't add parentheses yourself, Tosca Cloud processes the filters like this:

    (Electric==TRUE AND Brand==Mercedes) | Brand==Audi

    Which would return different data: all cars that are electric and Mercedes OR all cars that are Audis.

  • All cars that aren't Mercedes or Audi, where the mileage is greater than 1000: 

    !(Brand==Mercedes | Brand==Audi) & Mileage>1000

  • All registered cars that are either Mercedes with mileage over 1000, or Audi with mileage over 1000:

    Status==registered AND ((Brand==Mercedes AND Mileage>1000) OR (Brand==Audi AND Mileage>1000))

If your string contains special characters, you need to escape them:

  • To escape special characters, enclose the string with single quotation marks ('). Note that Tosca Cloud considers empty spaces as special characters.

  • To escape backslashes (\) and single quotation marks ('), add an additional escape character: a backslash (\). Example: FastFoodRestaurant=='McDonald\'s'

  • To escape double quotation marks ("), add an additional escape character: double quotation marks ("). Example: Actor=='Dwayne ""The Rock"" Johnson'

  • To signify numbers that Tosca Cloud should treat as text, enclose them with single quotation marks ('). Example: Order=='1524'

Reference the alias

To use the test data that Tosca Cloud stores behind an alias, enter the following:

{CTDS[<alias>.<column that has the data you want to use>]}

Reference the alias so you can use the data.

In this test case, you create an alias and then use the data row behind this alias. Specifically, you use the value that this row has in the LicensePlate column.

  1. Test step Create alias uses the module TestData - Find and provide item to create an alias called Audi2020Red. We're reusing the example from earlier.

  2. Test step Enter license plate steers two controls:

    • A text box called Plate number, where you want to enter the value of the LicensePlate column. To do so, enter {CTDS[Audi2020Red.LicensePlate]}.

    • A button called Next, where you want to perform a left-click. To do so, enter {Click}.

Screenshot of the example test case in Tosca Cloud.

Click to enlarge: Use the test data behind an alias