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.
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.