How to use Work Item Query Language (WIQL) to programmatically query for test
A WIQL query consists of a SELECT statement (similar to that of the SQL
language) that lists the fields to be returned as columns in the result set.
, you might use a WIQL query to specify the
in terms of TFS test cases, to which TA results are to be uploaded to
- Currently, in TestArchitect, the only supported type
of WIQL query is that which is used to query for test points.
- A test point is an object in the TCM Object Model. It represents a TFS
test case to be run against a test configuration in a test suite.
- In MTM, when you select Configurations, which displays the
number of test configurations that the test case is tested against in that test
, you see the list of test cases in each test suite. One of the
columns in the grid is
- Also in MTM, when you select test
, and then click on the same test suite, you see an entry in the
grid for each test case/test configuration combination. These are
A WIQL query consists of a SELECT statement
optionally, a qualifying WHERE clause.
The basic syntax is:
- TestPoint is case-sensitive.
- Since uploading TA test results to TFS requires the IDs of test cases residing in TFS,
ensure that the
set of the WIQL query consists of TFS test case IDs. To accomplish
that, it is
recommended that the SELECT * query be used. Note
also that the WIQL query for test points
not support returning specific values.
- The following table displays the list of TFS fields supported in WIQL
queries working with TestArchitect.
||Test Configuration that a test point is assigned to.
||Test suite and all its sub test suites (if any) that contain test
||Test suite that contains test points.
||ID of the test case.
||ID of the test plan.
the qualifying WHERE clause, the ID of the TFS
test plan is mandatory. At a given time, only a single TFS test plan is accepted in the
You can find test plan ID in the following:
Query to upload TA test results to TFS tests assigned to specific configuration
WHERE PlanId=<ID of test plan> AND
SuiteId=<ID of test suite> AND
ConfigurationId=<ID of configuration>
Suppose that you'd like to upload results to TFS with the following information:
- Demo_VSO test plan, ID 3160
- Calculation test suite, ID 3189
- Windows 7 – Oracle configuration, ID 20
The query selects test points where the PlanId field equals
3160, the SuiteId field equals
3189, and the ConfigurationId field equals
20. The query returns all information of the test point including test
case ID of the return set. Note that, as discussed above, test case ID is what we need to
retrieve in the returned result set.
WHERE PlanId=3160 AND
Tip: When you want to traverse TFS sub test suites recursively, change
SuiteId into RecursiveSuiteId. In this case, all
test cases below the specified test suite that satisfy the condition are returned.