【问题标题】:How to update test case in TFS using power tools?如何使用电动工具更新 TFS 中的测试用例?
【发布时间】:2016-12-08 09:58:57
【问题描述】:

有什么方法可以使用电动工具(命令行)更新 TFS 测试用例中的测试步骤? (寻找 MTM、Grid 和 3rd 方工具以外的解决方案)。

【问题讨论】:

    标签: powershell tfs tfs-power-tools


    【解决方案1】:

    不。 Microsoft 提供 MTM、Web 和 Grid。您会查看第三方工具。

    测试管理 Rest API:https://www.visualstudio.com/en-us/docs/integrate/api/test/cases

    然而,有一个 RestAPI(上面链接)和一个完整的客户端 API。两者都可以从 PowerShell 或 Code 访问。

    【讨论】:

      【解决方案2】:

      不,正如 MrHinsh 提到的那样,没有任何方法可以通过 Power Tools 更新测试步骤。如果您想从 powershell 更新测试步骤,您可以从 powershell 调用 TFS API,详细信息请参阅this link 中的“超越基础”部分。

      这里是更新测试步骤的代码:

      $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()
      

      【讨论】:

      • 非常感谢您的帮助...任何方式我们都可以在 excel 中将其作为宏...或在将读取 excel 文件的 power shell 中...这将避免代码与测试步骤....这也将保持格式...????同时我会检查链接并继续研究....
      • @basilbc 不,无论如何都无法从 excel 中使用宏来实现这一点。从powershell中读取excel文件,详细可以参考这个问题:stackoverflow.com/questions/19211632/…
      猜你喜欢
      • 1970-01-01
      • 2021-05-20
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多