我想知道是否可以将 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/