简体   繁体   English

当dotnet测试失败时,打破PowerShell脚本

[英]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.

相关问题 运行 `dotnet test` 时显示 `dotnet vstest` output 接收器的 output - When running `dotnet test` show output of the `dotnet vstest` output sink 由于对 Tizen 的依赖,`do.net test` 在 Maui 项目上失败 - `dotnet test` fails on a Maui project due to a dependency on Tizen Azure Pipelines:使用 -o 构建 dotnet 后 dotnet 测试失败 - “找不到任何兼容的框架版本” - Azure Pipelines: dotnet test fails after dotnet build with -o - "It was not possible to find any compatible framework version" 脚本通过 PowerShell 控制台正确运行,通过 C# 运行时失败 - Script runs correctly via PowerShell Console, fails when running via C# 当项目包含外语资源时,Dotnet 构建失败 - Dotnet build fails when project includes foreign language resources 由于传递依赖性,在提供运行时标识符时 Do.net 还原失败 - Dotnet restore fails when providing runtime identifier due to transitive dependency 什么是 Powershell(dotnet 全球) - What is Powershell (dotnet global) 以非 root 身份运行时无法在 docker 容器中运行 dotnet 测试 - Unable to run dotnet test in docker container when run as non root 使用 Connect-AzAccount 服务主体通过身份验证从 dotnet 中调用 PowerShell 脚本 - Invoking PowerShell script from within dotnet with authentication using Connect-AzAccount service principal 与 minimumExpectedTests 等效的 dotnet 测试 - dotnet test equivalent of minimumExpectedTests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM