如何在Azure DevOps(VSTS)中查询关联/未关联测试的工作项?
Hey there! Awesome that you're leveraging Azure DevOps (VSTS) work item queries—they're such a powerful tool for tracking your work. Let's tackle how to pull lists of work items that are linked to tests, and those that aren't, with clear steps and the right fields to use.
There are a couple of straightforward ways to find work items that have associated test cases, test plans, or test suites:
Use the Linked Work Items condition
In the query editor, add a new clause with these settings:- Field:
Linked Work Items - Operator:
Contains - Value:
Test Case(adjust this toTest PlanorTest Suiteif you're targeting those instead)
This will return any work item that has a direct link to a test case.
- Field:
Add relevant columns to visualize links
To see exactly which tests are linked, add these built-in columns to your query results:Linked Work Items: Shows all linked work items (including tests) in a single columnTest Cases: A dedicated column that only displays associated test casesTest Plan/Test Suite: If your tests are organized under plans/suites, these columns will show that hierarchy too
To find work items that have no associated tests, use one of these approaches:
Negate the Linked Work Items condition
Add a clause like this:- Field:
Linked Work Items - Operator:
Does Not Contain - Value:
Test Case
If you need to exclude multiple test-related work item types, use the
Not Inoperator and list all relevant types (e.g.,Test Case, Test Suite).- Field:
Check for empty Test Cases field
TheTest Casesfield automatically populates when a work item is linked to a test case. So you can use this simple clause:- Field:
Test Cases - Operator:
Is Empty
This is my go-to method because it's specifically targeted at test case associations, avoiding false negatives from other link types.
- Field:
Quick Pro Tip
Save these queries as shared queries in your project so your whole team can access them easily. You can also nest queries if you want to get fancy—for example, find user stories linked to failed test cases by combining a test case status filter with the link condition.
内容的提问来源于stack exchange,提问作者MajinBoo

