Dela via


How to: Create and Manage Queries for Searching

You can create and manage your queries to search for work items in your Team Foundation Server using Microsoft Test Manager. You can create the following types of queries:

  • Default query: Returns a flat list of work items

  • Direct links query: Returns work items and any work items that are linked to these items

  • Tree query: Returns a multi-tiered set of work items

These types of queries can also be created using Microsoft Visual Studio 2010. For more information about these types of queries, see Finding Bugs, Tasks, and Other Work Items.

There are two categories of queries.

  • Team Queries   These queries are available to everyone in your team project. Team Queries can only be created and modified by people who have been granted permission to create them by your team project administrator.

  • My Queries   These queries are available only to you.

To create and manage queries using Microsoft Test Manager, use the following procedures:

  • Create a subfolder to store a query

  • Create a query

  • Edit a query

  • Rename a query

  • Delete a query

Create a Subfolder to Store a Query

To create a subfolder to store a query

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.

  2. To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.

  3. In the center group menu bar, click Track and then click Queries.

    The Queries activity is displayed.

  4. To create a subfolder, right-click Team Queries folder, My Queries folder, or any other folder and then click New folder.

  5. Type the name for this new subfolder.

  6. To add a query to this new subfolder, right-click this new subfolder and then select the type of query that you want to create.

Create a Query

To create a query

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.

  2. To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.

  3. In the center group menu bar, click Track and then click Queries.

    The Queries activity is displayed.

  4. To select the folder where you want to create the query, click the folder in the queries folder hierarchy.

  5. To create a query, click the drop-down arrow next to Query, and point to the type of query that you want to create.

  6. To enter a name for this query, type the name.

    Important

    The first clause shown for the query makes sure that only items from your team project are returned in the results of the query. Do not change this clause.

    You can now add the clauses that you require for this query. For more information about how to specify the criteria for your query, see Specify Query Filter Criteria.

  7. (Optional) To change the columns or the sort order for the query results, click Column options.

    1. In the Column Options dialog box, select the columns to add from Available columns, and then click the arrow to add these columns to the Selected columns.

    2. Click Sorting and select the columns that you want to sort by.

    3. Click OK.

  8. (Optional) To group the query results by a column, drag a column header in the query results table to the title bar of the query results.

  9. When the query you created returns the work items that you want to view, click Save on the toolbar.

  10. The query is now saved.

Edit a Query

To edit a query

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.

  2. To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.

  3. In the center group menu bar, click Track and then click Queries.

    The Queries activity is displayed.

  4. To display the clauses for a query, click the query in the tree view in Queries.

  5. To update the query, edit the existing clauses or add new clauses.

  6. To see the results of your query, click Run to run the query.

  7. (Optional) To change the columns or the sort order for the query results, click Column options.

    1. In the Column Options dialog box, select the columns to add from Available columns, and then click the arrow to add these columns to the Selected columns.

    2. Click Sorting and select the columns that you want to sort by.

    3. Click OK.

  8. When the query you created returns the correct items that you want to view, click Save on the toolbar.

    The query is now updated.

Rename a Query

To rename a query

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.

  2. To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.

  3. In the center group menu bar, click Track and then click Queries.

    The Queries activity is displayed.

  4. To rename a query, right-click the query in the tree view in Queries and then click Rename.

  5. Type the new name for this query.

    The query is now displayed with the new name in the tree view of queries.

Delete a Query

To delete a query

  1. Open Microsoft Test Manager.

    Note

    To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.

  2. To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.

  3. In the center group menu bar, click Track and then click Queries.

    The Queries activity is displayed.

  4. To delete a query, right-click the query in the tree view in Queries and then click Delete.

    A confirmation dialog box is displayed.

  5. To confirm deletion of the query, click Delete query.

    The query is no longer displayed in the tree view of queries.

See Also

Tasks

How to: Search for Test Cases from Microsoft Test Manager