testing - TFS 2013 将测试用例关联自动化链接到 xUnit 测试

标签 testing nunit xunit

我想知道是否可以将 TFS 2013 中的测试用例链接到 xUnit 测试。目前它适用于 msTest 测试,但是一旦我将方法属性从“TestMethod”更改为“Fact”并重建,当我单击测试用例中的关联自动化将两者链接在一起时,测试不再出现。

有人对此有任何经验或答案吗?

谢谢

最佳答案

使用 TFS API 是可能的。此 PowerShell 脚本向您展示了如何执行此操作(请参阅:https://blogs.msdn.microsoft.com/gautamg/2012/01/01/how-to-associate-automation-programmatically/ 以供引用)。

# Get TC
$tfsTpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($TPC_URL)
$tms = $tfsTpc.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService])
$tp = $tms.GetTeamProject($TP_NAME)
$tc = $tp.TestCases.Find($tcId)
# Compute Automation Guid
$sha1Crypto = new-object System.Security.Cryptography.SHA1CryptoServiceProvider
[Byte[]] $bytes = New-Object Byte[] 16
[Array]::Copy($sha1Crypto.ComputeHash([System.Text.Encoding]::Unicode.GetBytes($testName)), $bytes, $bytes.Length)
# Create association
$tc.Implementation = $tp.CreateTmiTestImplementation($testName, $AUTOMATION_TYPE, $AUTOMATION_STORAGE_NAME, $automationGuid)
$tc.Save()
$automationGuid = New-Object -TypeName Guid -ArgumentList @(,$bytes)

但是您将无法将执行与 TFS 中的测试用例相关联。

测试必须使用 MSTest V1 运行,以将结果记录为有效的 TRX,以通过 TCM.exe 在 TFS 中发布。即使使用 vstest.console.exe 和 TRX 记录器选项,TCM.exe 也无法理解 xml 结果。

引用:http://bugsareinthegaps.com/uploading-automated-test-results-to-mtm-made-easy/

关于testing - TFS 2013 将测试用例关联自动化链接到 xUnit 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27381947/

相关文章:

c# - 从 Teamcity 获取 NUnit 测试结果报告

c# - 如何在 Xunit 中创建基测试类来测试接口(interface)实现?

Mac OS X 10.5 上的 ASP.net 测试服务器?

c# - 如何对与串口接口(interface)的软件进行集成测试?

java - 单元测试 : Is it bad practice to call public methods (for setup) while testing another method?

selenium - 使用 Selenium 在 xUnit 中进行跨浏览器测试

unit-testing - 如何测试私有(private)目录中的功能?

testing - cucumber 背景与 Hook 前的对比

html - 使用发布请求确认 onclick 确认对话框

syntax - Assert.That 和传统语法之间在功能上有区别吗?