How to delete test cases from Team Foundation Server

不问归期 提交于 2019-12-01 11:55:05

witadmin is not part of TFS Power Tools and should be available from the Visual Studio Command Prompt on the default instalation of Visual Studio and Team Explorer.

If for any reason it isn't available, you should be able to find it at "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE" or an equivalent path in case Visual Studio was installed elsewhere.

There shouldn't be any spaces between the parameter name and the parameter itself and multiple IDs can be specified by delimiting them with commas:

witadmin destroywi /collection:host\collection /id:3,5,7

EDITED to include new requirements from the OP

If you need more flexibility in determining what work items are to be destroyed, you should resort to Team Foundation's client API. In the sample below, I created a console application that receives two parameters: The Team Project's name and a WIQL query:

using System;
using System.Linq;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace DelWi {
    class Program {
        static void Main(string[] args) {
            var store = new WorkItemStore(args[0]);
            WorkItemCollection workItems = store.Query(args[1]);
            if (workItems.Count == 0) {
                Console.WriteLine("No work items with the specified criteria.");
            }
            var query = from workItem in workItems.Cast<WorkItem>()
                        select workItem.Id;
            foreach (var item in store.DestroyWorkItems(query)) {
                Console.WriteLine("{0}\t{1}", item.Id, item.Exception.Message);
            }
            Console.WriteLine("Press any key to continue...");
            Console.Read();
        }
    }
}

Once compiled you can call it passing the parameters such as in:

DelWi.exe "host\defaultcollection" "SELECT * FROM WorkItems WHERE [System.TeamProject] = 'The Best Team Project Ever'  AND  [System.WorkItemType] = 'Test Case'  AND  [System.Id] > 34  AND  [System.Id] < 37"

Be careful though, because if you don't specify the query correctly you may end up deleting more work items than you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!