Create and use test case templates
A test case template is a core component of test case design. It's a blueprint based on an existing test case, and you'll use it to create a whole set of additional test cases.
This topic explains all things test case template: how to create one, prepare and link a test sheet, map values, and generate test cases from it.
Your templates are also available in the inventory. Find them in the Templates tab under Build > All assets.
Before you start
You need a test case to create your template. Make sure it covers the flow you want to test.
Create a test case template
To create a template, go to the test case you want to be your template and select Create template. Tosca Cloud keeps the test case, creates the template, and takes you to the template.
Prepare and link your test sheet
Your template needs a test sheet that defines the elements you want to test and the input values you'll allow. If you don't have one yet, build your test sheet.
Create test case instances
Before you can link your test sheet to your test case template, you need to create test case instances. A test case instance is one specific combination of values from your test sheet. Tosca Cloud generates one test case from each instance. Create your test case instances if you haven't already.
Link your test sheet
To link your test sheet, go to your test case template and select Link to a test sheet.
Then, go to the test step where you want to use input values. Under Value, enter {XL[<test sheet attribute>]}. Replace <test sheet attribute> with the attribute name from the test sheet. Use a dot to separate nested levels. For example, login.username.
Your recovery and cleanup scenarios can also reference test sheet values. This way, each scenario instance uses the right data for its test case.
Use relative paths
To avoid repeating a full reference in every test step value, use relative paths to set the shared part once in the Path column. Then, write only what's unique in each value.
To do this, go to the Path column and enter the shared part of the path. Use a dot to separate nested levels.
Then, under Value, add a relative reference. Start with a dot, followed by just the part that's unique. Auto-completion follows your Path level, so it only suggests attributes below it instead of listing every attribute in the test sheet.
For example, your test sheet has this structure:
-
checkout
-
customer
-
login
-
username
-
password
-
-
-
Set Path to checkout.customer.login for the login branch, then reference username and password with {XL[.username]} and {XL[.password]}.
Path values stack across nested folders. An outer test step folder can have Path set to checkout.customer, and the folder inside it can have Path set to .login. Together, they make checkout.customer.login for anything nested inside, including test steps without a set Path.
Each dot-prefixed Path value adds onto the closest one above it, however many levels up that is. A Path value without a leading dot is a full path on its own and ignores everything set above it.
Tosca Cloud supports relative paths on the following elements:
-
Test steps and test step values.
-
Test step folders.
-
Business parameters in reusable test steps.
-
IF, WHILE, and DO logic elements.
-
Recovery and cleanup scenarios, including recovery scenario collections.
The Path value on IF, WHILE, and DO logic elements applies only to the element itself, not to its THEN, ELSE, condition, or loop parts.
Check your template
Before you generate test cases, use the template check to find broken input values and conditions. To run it, go to your template, select
, and select Run check. Tosca Cloud validates the following:
-
Instantiation conditions, including their syntax and referenced attributes.
-
Test sheet references in test step values ({XL[]}), including their syntax, referenced attributes, and nested paths such as Parent.Child.
Generate test cases from your template
Now that you've linked your test case template to a test sheet, you're ready to generate test cases. Tosca Cloud creates one test case for each test case instance in your test sheet.
To generate test cases, go to your test case template and select Instantiate. Your test cases appear in the Relations tab of the asset panel.
Each template instance shows which test sheet it came from. To go to the linked test sheet, select Go back to test sheet at the top of the template instance.
Update test cases from your template changes
If you change your template after you generate test cases, you can update. After you make your changes, select the template instance you want to update and select Reinstantiate.
Switch the linked test sheet
If you need to use a different test sheet, link the template instance to it and regenerate the test cases.
To do so:
-
Open the template instance and select Update link.
-
In the Update link and reinstantiate? dialog, select the test sheet you want to link to.
-
Select Update and reinstantiate.
Tosca Cloud links the template instance to the new test sheet and regenerates the test case.
Use instantiation conditions
You can include or exclude specific test steps from test case instances, depending on their values.
To do so, add an instantiation condition:
-
In your test case template, select the test step, folder, or recovery and cleanup scenario you want to add an instantiation condition to.
-
In the Properties tab, add a value under Instantiation condition. Use the following syntax:
<test sheet attribute><operator>"<value>"
-
Replace <test sheet attribute> with the attribute name from the test sheet. Use a dot to separate nested levels. For example, login.username.
-
Replace <operator> with a valid operator such as == or !=.
-
Replace <value> with the value you want between double quotation marks.
For example login.username=="alex.ample@email.com".
-
Valid operators
The following table describes the valid operators you can use in your XL expression:
|
Operator |
Description |
Example |
|---|---|---|
|
AND |
True when both criteria are met. |
login.username=="alex.ample@email.com" AND login.password=="valid123" |
|
OR |
True when at least one criterion is met. |
login.username=="alex.ample@email.com" OR login.username=="jordan.smith@email.com" |
|
NOT |
Excludes instances where the condition is true. |
NOT(login.username=="alex.ample@email.com") |
|
== |
Includes instances where the value is equal to the specified value. |
login.username=="alex.ample@email.com" |
|
=i= |
Includes instances where the value is equal to the specified value, case insensitive. |
login.username=i="ALEX.AMPLE@EMAIL.COM" |
|
!= |
Includes instances where the value is not equal to the specified value. |
login.username!="alex.ample@email.com" |
|
!i= |
Includes instances where the value is not equal to the specified value, case insensitive. |
login.username!i="ALEX.AMPLE@EMAIL.COM" |
|
< |
Includes instances where the value is less than the specified value. |
user.age<"65" |
|
> |
Includes instances where the value is greater than the specified value. |
user.age>"21" |
|
<= |
Includes instances where the value is less than or equal to the specified value. |
user.age<="65" |
|
>= |
Includes instances where the value is greater than or equal to the specified value. |
user.age>="21" |
|
=~ |
Includes instances where the value matches a regular expression. |
login.username=~"^alex" |
|
=i~ |
Includes instances where the value matches a regular expression, case insensitive. |
login.username=i~"^alex" |
|
=? |
Includes instances where the value contains the specified string. |
login.username=?"alex" |
|
=i? |
Includes instances where the value contains the specified string, case insensitive. |
login.username=i?"alex" |
|
!? |
Includes instances where the value doesn't contain the specified string. |
login.username!?"alex" |
|
!i? |
Includes instances where the value doesn't contain the specified string, case insensitive. |
login.username!i?"alex" |
What's next
Now that you've generated test cases, do a few trial runs to find and fix any issues before you create playlists.