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

09-12 06:05