Example TQL solutions
The examples in this chapter illustrate how typical problems are solved using TQL and the sample application Vehicle insurance calculator. TestCase and Module have been selected in the examples below in order to search for their properties.
The illustration below shows the search query which returns the result layer 4 for each hierarchical layer.
Source object dependent search query
Any number of individual search queries can be arbitrarily put together and combined. |
In the examples below, the source object of the search query is the TestCases folder, if not explicitly stated.
TestCase name
Current situation
Example - current situation
Task
Search for all TestCases in the TestCases folder that have the name Data Source Excel.
Solution
=>SUBPARTS:TestCase[Name=="Data Source Excel"]
Hierarchical levels
Current situation
Example - current situation
Task
Search for all TestCases with the name Data Source Excel, which are located exactly 3 levels below the TestCases folder.
Solution
->SUBPARTS->SUBPARTS->SUBPARTS:TestCase[Name=="Data Source Excel"]
A level can be explicitly selected with the simple arrowOperator ->. The number of usages determines the level.
Exclusion
Current situation
Example - current situation
Task
Search for all TestCases that do not contain the name Data Source Excel.
Solution
=>SUBPARTS:TestCase[Name!="Data Source Excel"]
TestStepValue
Current situation
Example - current situation
Task
Search for all TestCases that contain a TestStepValue with the value Motorcycle.
Solution
First, all TestStepValues with the corresponding value are searched for. Since TestCases are being searched, the parent object must be addressed on all levels using =>SUPERPART.
=>SUBPARTS:TestStepValue[Value=="Motorcycle"]=>SUPERPART:TestCase
Alternative
With RETURN, you can specify which objects should be returned.
=>RETURN SUBPARTS:TestCase=>SUBPARTS:TestStepValue[Value=="Motorcycle"]
The RETURN command is not displayed during automatic completion. A subsequent space is therefore required. |
Type Template
Current situation
Example - current situation
Task
Search for all TestCases that are templates. The query need not be case sensitive.
Solution
=>SUBPARTS:TestCase[IsTemplate=i="true"]
The required elements are found by means of a TestCase property.
The operator =i= stands for a comparison that is not case sensitive.
Linked Search
Current situation
Example - current situation
Task
Search for all TestCases that are templates and have the TestCase name Truck 01.
Solution
=>SUBPARTS:TestCase[(IsTemplate=="True") AND (Name=="Truck 01")]
LockedBy
Task
Revoke the checkout of OwnedItem (ExecutionLists, ExecutionLogs) of a specific user only.
Solution
=>RETURN SUBPARTS:OwnedItem[CheckOutState=="CheckedOut"]->LockedBy[Name=="samuel_smith"]
Substring
Current situation
Example - current situation
Task
Search for all TestCases that have Truck in their names.
Solution
=>SUBPARTS:TestCase[Name=?"Truck"]
Regular expressions
Current situation
Example - current situation
Task
Search for all TestCases with a name beginning with automobile.
Solution
=>SUBPARTS:TestCase[Name=~"^automobile"]
Search for all TestCases that use a particular Module
Current situation
Example - current situation (TestCases)
Example - current situation (Modules)
Task
Search for all TestCases that use the Module Vehicle data.
Solution
The starting point of the search is the Module folder.
=>SUBPARTS:Module[Name=="Vehicle data"]
=>AllReferences=>SUPERPART:TestCase
Solution - Description
First, all Modules of the name Vehicle data are searched. The second ArrowOperator points to all referenced objects (TestSteps, ModuleAttributes, the ObjectMap, Folder and User). Only the TestSteps are relevant for this task, as they are linked explicitly to the searched TestCases. These superior elements are accessed with "=>SUPERPART:TestCase".
Alternative solution
The starting point of the search is the Module folder.
=>SUBPARTS:Module[Name=="Vehicle data"]->TestSteps=>SUPERPART:TestCase
Note
A set union can be used to search for all TestCases which use at least one Module specified in the search query.
Task
Search for all TestCases that use Module1 and/or Module2.
Solution
The starting point of the search is the TestCases folder.
->UNION(=>return SUBPARTS:TestCase=>SUBPARTS:TestStep->Module[Name=="Module1"],=>return SUBPARTS:TestCase=>SUBPARTS:TestStep->Module[Name=="Module2"])
Search all XModules
Task
Search for all XModules.
Solution
=>SUBPARTS:XModules
Tricentis Tosca uses Modules and XModules. For more information, see chapter "Create and manage Modules". |
Search for properties of objects
Current situation
Example - current situation
Task
A user-defined TestCase property has the name TestProp1. Search for all TestCases where this property has the value Test-01. The query need not be case sensitive.
Solution
The starting point of this search is the TestCases folder .
=>SUBPARTS:TestCase[TestProp1=i="test-01"]
Current situation
Example - current situation
Task
A user-defined TestCase folder property is named TestProp2. Search for all TestCase folders where this property has the value Test-02. The query need not be case sensitive.
Solution
The starting point of this search is the project root element.
=>SUBPARTS:TCFolder[TestProp2=i="test-02"]
Current situation
Example - current situation
Task
A user-defined Module property has the name TestProp3. Search for all Modules where this property has the value Test-03. The query need not be case sensitive.
Solution
The starting point of this search is the Modules folder .
=>SUBPARTS:Module[TestProp3=i="test-03"]
Search for TechnicalIDs
Current situation
Example - current situation
Example - current situation
Task
Search for the TechnicalID TechnicalID=YearOfConstruction.
Solution
The starting point of this search is the Modules folder.
=>SUBPARTS[TechnicalId=="ID=YearOfConstruction"]
Additional task
Parent Modules should be found.
Solution
The starting point of this search is the Modules folder. The expression is completed with =>SUPERPART:Module
Final solution
=>SUBPARTS[TechnicalId=="ID=select_YearOfConstruction"]=>SUPERPART:Module
Note
Several, different objects have the Attribute TechnicalID. Accordingly, the position of the TechnicalIDs is independent of the object and may be different.
Current situation
Example - current situation
Task
Search for TechnicalIDs of Modules. This TechnicalID is located under the ObjectMap.
Solution
The starting point of this search is the Modules folder.
=>SUBPARTS:ObjectMap[TechnicalId=="Caption=TRICENTIS Vehicle insurance calculator*"]
Current situation
Example - current situation
Task
Search for TechnicalIDs of ModuleAttributes. This TechnicalID is located under the ObjectControl.
Solution
The starting point of this search is the Modules folder.
=>SUBPARTS:ObjectControl[TechnicalId=="ID=edit_price"]
Search for Modules which are not used in TestCases
Current situation
Example - current situation (Modules)
Example - current situation (TestCases)
Task
Search for all Modules, which have not yet been used in TestCases.
Solution
The starting point of this search is the Modules folder.
=>COMPLEMENT(=>SUBPARTS:Module,=>RETURN SUBPARTs:Module->TestSteps)
Solution - description
COMPLEMENT allows a complementary set to be searched. The first query searches all Modules, while the second searches all Modules used in TestCases. The complementary set of these two queries contains all Modules, which are not yet used in a TestCase.
Search for TestCases which are not linked to Requirements
Current situation
Example - current situation (Requirements)
Example - current situation (TestCases)
Task
Search for all TestCases, which have not been linked to Requirements yet. (The Tosca Requirements Management AddIn is required for the search.)
Solution
The starting point of this search is the project root element.
=>COMPLEMENT(=>SUBPARTS:TestCase, =>SUBPARTS:RequirementTestCaseLink->TestedBy)
Solution - description
COMPLEMENT allows a complementary set to be searched. The first query searches all TestCases, while the second searches all TestCases containing a RequirementTestCaseLink. The complementary set of these two queries contains all TestCases, which have not been linked to Requirement yet. TestedBy is used for directly referencing to the TestCases.
Search for TestCases, which are not assigned to any ExecutionList
Current situation
Example - current situation
Task
Search for all TestCases, which have not been assigned to an ExecutionList yet.
Solution
The starting point of this search is the TestCases folder.
=>COMPLEMENT(=>SUBPARTS:TestCase, =>RETURN SUBPARTS:TestCase->ExecutionEntries)
Solution - description
COMPLEMENT allows a complementary set to be searched. The first query searches all TestCases, while the second searches all TestCases that are linked to an ExecutionEntry. The complementary set of these two queries contains all TestCases, which do not yet have any ExecutionEntry defined.
Search for all ExecutionEntries, whose recent result has changed compared to another execution
Task
Search for all ExecutionEntries, whose execution state has changed from Passed to Failed between two test executions.
Solution
The starting point of this search is the ExecutionLists folder.
=>return SUBPARTS:ExecutionEntry->INTERSECTION(
->TestCase,
=>SUPERPART:ExecutionList->ExecutionLogs[Name == "ActualLog"]->TestCaseLogs[Result == "Failed"]->ExecutedTestCase,=>SUPERPART:ExecutionList->ExecutionLogs[Name == "Run1"]->TestCaseLogs[Result == "Passed"]->ExecutedTestCase
)
Solution - description
The search returns all subelements of an ExecutionEntry, which point to an element that is defined by INTERSECTION.
INTERSECTION means the intersection of three partial results:
-
Set of all TestCases
-
Set of all TestCases, which are marked as Failed in the ActualLog
-
Set of all TestCases, which are marked as Passed in the ExecutionLog Run1
The expression =>SUPERPART is used to move from ExecutionEntries to ExecutionLists.
The search returns all TestCases, which are marked as Failed in the ActualLog, but were previously Passed when Run1 was executed. The reversed search may be useful in a different context.
A similar search allows TestCases to be searched in the ActualLog, which have not yet been executed, but which have a result in log Run1.
=>return SUBPARTS:ExecutionEntry->INTERSECTION(
->TestCase,
=>SUPERPART:ExecutionList->ExecutionLogs[Name == "ActualLog"]
->TestCaseLogs[(Result != "Failed") AND (Result != "Passed")]->ExecutedTestCase,
=>SUPERPART:ExecutionList->ExecutionLogs[Name == "Run1"]
->TestCaseLogs[(Result == "Passed") OR (Result == "Failed")]->ExecutedTestCase
)
Search for TestCases which are linked to Requirements, but do not yet exist in an ExecutionList
Task
Search for TestCases which are linked to requirements, but do not yet have an ExecutionEntry in an ExecutionList.
Solution
The starting point of this search is the project root element
->PROJECT->COMPLEMENT(=>SUBPARTS:RequirementSet[NodePath=="/Requirements/RS"]=>SUBPARTS:RequirementTestCaseLink->TestedBy,
=>SUBPARTS:RequirementSet[NodePath=="/Requirements/RS"]->UnconfiguredExecutionListLinks->ExecutedBy=>SUBPARTS:ExecutionEntry->TestCase)
Solution - description
The command COMPLEMENT is used to search for a complementary set.
The first query starts from the project root element and searches recursively for requirements which exist in a RequirementSet RS and are linked to TestCases.
The second query also starts from the project root element and searches for ExecutionLists that are linked to a RequirementSet RS. The search returns all TestCases that are linked to an ExecutionEntry of a linked ExecutionList.
TestCases that are not linked to ExecutionEntries
Search for occurrences of specific values
Task
Search for objects with a specific value in their Value.
Solution
->SUBPARTS:OwnedItem['<ANY>'=="letter" OR '<ANY>'=="number"]
Solution - description
This query searches one level below the selected element for all objects whose Value contains letter, number or both values.
Search for test configuration parameters of specific values
Task
Search for all TestCases whose test configuration parameter contains a specific value. Inherited values should be considered in the search.
Solution
=>SUBPARTS:TestCase[EVALCP("Browser") == "InternetExplorer"]
Solution - description
This query searches all levels beneath the selected element for all TestCases which contain a test configuration parameter Browser having the value InternetExplorer.
Task
Search for all TestCases which contain an initially created test configuration parameter of a specific value. Inherited values should not be considered in the search.
Solution
=>SUBPARTS:TestCase[Browser == "InternetExplorer"]
Solution - description
This query searches all levels beneath the selected element for all TestCases which contain an initially created test configuration parameter Browser having the value InternetExplorer.
Search for Modules which are not assigned to a TestCase
Task
Find out whether there are Modules which are not assigned to any TestCase.
Solution
=>SUBPARTS:Module[COUNT("TestSteps")==0]
Solution - description
All Modules beneath the selected element are searched by using =>SUBPARTS:Module
.
The expression [COUNT("TestSteps")==0]
is used to search for all Modules which are not linked to any TestSteps.