通过 Powershell Invoke-Command 执行 VSTest.Console.exe 测试
Executing VSTest.Console.exe test via Powershell Invoke-Command
所以我正在尝试使用 Powershell 的 Invoke-Command 通过 VSTest.Console.exe 启动测试 运行s。我是 powershell 的新手,但脚本如下所示:
$secpasswd = ConvertTo-SecureString “P@ssword01” -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 $credentials”和 运行 它,它 运行s 并且我们得到测试结果回来就好了。我可能在这里遗漏了什么?
好的,所以我一直看错了。本练习的目的是使用 TeamCity meta运行ner 进行 运行 测试。实际上有一个 Visual Studio 测试 运行ner 可用,它可以代替繁重的工作。只需要退后一步,用新的眼光看待它!
所以我正在尝试使用 Powershell 的 Invoke-Command 通过 VSTest.Console.exe 启动测试 运行s。我是 powershell 的新手,但脚本如下所示:
$secpasswd = ConvertTo-SecureString “P@ssword01” -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 $credentials”和 运行 它,它 运行s 并且我们得到测试结果回来就好了。我可能在这里遗漏了什么?
好的,所以我一直看错了。本练习的目的是使用 TeamCity meta运行ner 进行 运行 测试。实际上有一个 Visual Studio 测试 运行ner 可用,它可以代替繁重的工作。只需要退后一步,用新的眼光看待它!