[英]Break PowerShell Script when dotnet test fails
In a small PowerShell build script I build and test a .NET application. 在一个小的PowerShell构建脚本中,我构建并测试了一个.NET应用程序。
I now want to prevent further steps in the script if the tests result in one or more failures. 我现在想要在测试导致一个或多个失败时阻止脚本中的进一步步骤。
I tried to get the result of the test like this: 我试着像这样得到测试的结果:
$exitcode = dotnet test .\Domain.Tests
Write-Host "result $exitcode"
but unfortunately it doesn't return an exit code indicating success I just get the test testing description. 但遗憾的是它没有返回退出代码表示成功我只是得到了测试测试说明。
Is there a better way then parsing the string output for the failed tests count? 有没有更好的方法然后解析失败的测试计数的字符串输出?
有一个$lastexitcode
自动变量,你可以检查退出代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.