Posts

Showing posts with the label TFS API

TFS API: Get Work Item History Revisions for parituclar Field

Image
Hello, I observed many of us struggling to view history for any work item. History is visible but it is hard to visualize changes made like who made changes, to which field and when etc. For this matter, one has to scroll through entire history tab and find it tedious job. I was thinking what if we could view work item history for selected field with other details like who changed it and when. Here is solution - I have created a tool which show work item history for selected field. Also shows how may times selected field changed. You can view history by selecting single work item and also export entire work item query history to excel. I find this tool useful so thought of sharing with others. How it works - 1. Run EXE 2. Prompt you select/add team project server details 3. Populates your My Queries to Treeview 4. Double Click query from tree and it will show work items in right grid 5. Select Work item field from top drop down for which you want to see history ...

TFS API: How to get latest test result for a test case

We can retrieve test results for particular test case using TFS API. That's straight forward and there are in build methods. I find people asking for how they can retrieve latest test result for particular test case and I got it solved so thought of sharing here. below code snippet will illustrate how to - 1. Connect to TFS Server/Collection/team project Uri tfsUri = new Uri( "http://servername:8080/tfs/collectionname" ); teamProjectCollection = new TfsTeamProjectCollection(tfsUri);   iTestManagementService = teamProjectCollection.GetService<ITestManagementService>(); tfsConnectedTeamProject = iTestManagementService.GetTeamProject( "Team Project Name" );   2. Once connected to TFS server, call APIs to get test results for any particular test case. Below line of code will get all results associated with passed test case Id and this returned list is not sorted var testResults = tfsConnectedTeamProject.TestResults.ByTestId(52737); 3. W...

Add attachment to Test Case Result using TFS API

We can add attachment to test case result using TFS APIs. Here is small code snippet I have created. ITestRun testRun = _plan . CreateTestRun ( false ); ITestCaseResultCollection results = testRun . QueryResults (); ITestIterationResult iterationResult ;   foreach ( ITestCaseResult result in results ) {      result . Attachments . Add ( new Attachment ( "FileName" , "Comments if any" )); }   results . Save ( true ); testRun . Save (); testRun . Refresh ();