我正在尝试使用PowerShell运行一些单元测试。我有一个(有点)能用的命令:
$output = & $vsTestPath $TestAssembly $logger $TestCaseFilter 2>&1
这种方法存在一个问题,标准输出和标准错误流的输出顺序不正确,它们会混合在一起。从这里得到的一个解决方案是使用cmd.exe,但我无法让它工作。我感觉自己已经尝试了所有能想到的方法。
以下是我所拥有的内容:
$vsTestPath = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
$TestAssembly = "C:\IntegrationTesting\Test Application\Ads.Slms.IntegrationTesting.Web.Smartfill.dll"
$output = & cmd.exe /c $vsTestPath $TestAssembly 2`>`&1
这最后一行不起作用。奇怪的是,如果我只写
$output = & cmd.exe /c $vsTestPath 2`>`&1
然后这个运行了,但是对我没有用。问题在于第二个参数。我尝试了其他的东西。我该如何让它运行呢?
$output = & cmd.exe /c $vsTestPath $TestAssembly 2`>`&1
$output = & cmd.exe /c $vsTestPath,$TestAssembly 2`>`&1
$output = & cmd.exe /c "$vsTestPath" $TestAssembly 2`>`&1
$output = & cmd.exe /c """$vsTestPath""" $TestAssembly 2`>`&1
$output = & cmd.exe /c "$vsTestPath" "$TestAssembly" 2`>`&1
$output = & cmd.exe /c """$vsTestPath""" """$TestAssembly""" 2`>`&1
$output = & cmd.exe /c '"' $vsTestPath $TestAssembly '2>&1' '"'
- user4003407$output = cmd.exe /c $vsTestPath $TestAssembly 2
>&1
。 - mhatch73