2016-04-21 108 views
0

所以我試圖通過使用Powershell的Invoke-Command通過VSTest.Console.exe啓動測試運行。我是很新,PowerShell的,但劇本是這樣的:通過Powershell Invoke-Command執行VSTest.Console.exe測試

$secpasswd = ConvertTo-SecureString 「[email protected]」 -AsPlainText -Force 
$credentials = New-Object System.Management.Automation.PSCredential (「administrator」, $secpasswd) 
$shareName = "testruns" 

#Script block to execute on the remote machine 
$scriptBlock = { 
param($shareName, $testRunId, $myTestContainers, $testCategory) 
$localFolder = "c:\$shareName\" + $testRunId 
$exePath = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" 

$argList = @() 
#Add the containers 
$myTestContainers.Split(",") | foreach { 
    $argList += "`"$localFolder\$_`" " 
} 

$argList += "/logger:trx" 
$argList += "/settings:$localFolder\remote.testsettings" 
$argList += "/Platform:x64" 
$argList += "/Framework:Framework45" 

#Let everyone know whats happening 
Write-Output "Args: $argList" 

#Do it 
& $exePath $argList 
} 

#Invoke the script block 
Invoke-Command -ScriptBlock $scriptBlock -Credential $credentials -ComputerName 10.123.123.12 -ArgumentList testruns, "1.2.3456", "CaiConTest.dll,CsiConTest.dll", "" 

後60秒,這是返回:

Error: Failed to initialize client proxy: could not connect to test process . 
+ CategoryInfo   : NotSpecified: (Error: Failed t... test process .:String) [], RemoteException 
+ FullyQualifiedErrorId : NativeCommandError 
+ PSComputerName  : 10.123.123.12 

Error: There was no endpoint listening at net.pipe://mymachineFQDN/TestExecutor/5208 that could accept the message. This is often caused by an incorrect address or SOAP action. See 
InnerException, if present, for more details. 

我發現,如果我刪除「-Credential $憑據「並在同一臺機器上運行它,我正在調用該命令,它運行,我們得到的測試結果很好。我可能會在這裏錯過什麼?

回答

1

好吧,所以我一直在看這一切都是錯誤的。這個練習的目的是使用TeamCity的metarunner來運行測試。實際上有一個Visual Studio測試運行器可以完成繁重的工作。只需要退後一步,用新鮮的眼睛看看它!