2016-04-21 107 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测试运行器可以完成繁重的工作。只需要退后一步,用新鲜的眼睛看看它!