1

Is there any way we can update test steps in a test case in TFS using power tools (command line) ? (Looking for solution other than MTM, Grid & 3rd party tools).

basilbc
  • 69
  • 1
  • 1
  • 9

2 Answers2

2

Nope. Microsoft provide MTM, Web, and Grid. You would be looking at third party tools.

Test Management Rest API: https://www.visualstudio.com/en-us/docs/integrate/api/test/cases

There is however both a RestAPI (linked above) and a full client API. Both of which can be accessed from PowerShell or Code.

2

No, there isn't any way to update the test steps via Power Tools just as MrHinsh mentioned. If you want to update the test step from powershell, you can call the TFS API from powershell, refer to "Beyond the basics" section in this link for details.

Here is the code to update the test steps:

$collectionurl = "http://TFSCollectionURL/";
$tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($collectionurl);
##$buildservice = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]);
##$workitemservice = $tfs.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore]);
$testservice = $tfs.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService])
$project = "ProjectName";
$testcaseid = 1;
$testproject = $testservice.GetTeamProject($project);
$testcase = $testproject.TestCases.Find($testcaseid);
##Update the first step
$teststep1 = $testcase.Actions[0]
$teststep1.Title = "New Action"
$teststep1.ExpectedResult = "New Expected Result"
##Update the second step
$teststep2 = $testcase.Actions[1]
$teststep2.Title = "New Action"
$teststep2.ExpectedResult = "New Expected Result"
$testcase.Save()
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • Thanks a lot for the help...Any way we can have this in excel as a macro...or in power shell that will read an excel file.. which will avoid mixing of code with test step....also will this maintain formatting...???? Meanwhile I will check the links and will continue research.... – basilbc Dec 11 '16 at 01:26
  • @basilbc No, there isn't anyway to achieve this from excel with macro. For reading an excel file from powershell, you can refer to this question for details: http://stackoverflow.com/questions/19211632/read-excel-sheet-in-powershell – Eddie Chen - MSFT Dec 12 '16 at 03:12