如何使用Powershell脚本在解决方案目录中运行所有单元测试。 我尝试使用以下命令
$tool = '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe"'
$x = ""; dir D:\DropBuildOutput\*.Tests.dll -Recurse | foreach { $x += "/testcontainer:""$_"" " }; iex "$tool $x"
但它失败了以下错误。我如何运行所有测试并生成结果?
iex : At line:1 char:79
+ ... (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcont ...
+ ~
You must provide a value expression following the '/' operator.
At line:1 char:79
+ ... STest.exe" /testcontainer:"D:\DropBuildOutput\_PublishedWebsites\SCJ. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token
'testcontainer:"D:\DropBuildOutput\_PublishedWebsites\aaa.aaa.aaa.aaa\bin\xxx.aaa.aaa.Tests.dll"' in
expression or statement.
At line:2 char:100
+ ... -Recurse | foreach { $x += "/testcontainer:""$_"" " }; iex "$tool $x"
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression,Microsoft.PowerShell.Commands.InvokeExpressionCommand
答案 0 :(得分:0)
使用呼叫运营商&
代替Invoke-Expression
:
& $Tool $x