首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >即使在dotnet测试报告错误时,GitHub操作也标志着成功运行。

即使在dotnet测试报告错误时,GitHub操作也标志着成功运行。
EN

Stack Overflow用户
提问于 2022-07-04 14:28:42
回答 1查看 110关注 0票数 0

我在windows运行程序上使用dotnet test有一个简单的问题。当运行多个测试时,只考虑最后一个退出代码。

代码语言:javascript
复制
- name: Run unit tests
run: |
  dotnet test ./tests/ProjectA/ProjectA.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
  dotnet test ./tests/ProjectB/ProjectB.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
  dotnet test ./tests/ProjectC/ProjectC.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full

让我们假设ProjectAProjectB确实有测试,但失败了。因此,退出代码为非零。在ubuntu-latest上,一切正常,运行被报告为失败,但在windows-latest上,运行被报告为成功。

所起的作用是通过&&链接这些命令,以便只有在当前命令成功的情况下才运行下一个命令。这种方法的问题是,第一个失败的测试套件会停止整个运行。在windows和非windows运行程序之间进行切换是没有问题的。

EN

回答 1

Stack Overflow用户

发布于 2022-09-11 11:58:47

考虑到最后一个退出代码的原因是,对dotnet测试的3个调用将按顺序运行。"run“的输出将只包含一个退出代码,因此,第二个命令覆盖第一个命令结果,第三个覆盖第二个命令。

在我看来,你有三个选择:

suggested.

  • Split
  1. 运行一个组选项,例如在解决方案级别上运行测试。
  2. 使用&&作为一个命令运行测试,因为您已经在操作中将这3个命令分成不同的步骤。例如

。。

代码语言:javascript
复制
- name: Run unit tests projectA
run: |
  dotnet test ./tests/ProjectA/ProjectA.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full

- name: Run unit tests projectB
run: |
  dotnet test ./tests/ProjectB/ProjectB.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full

- name: Run unit tests projectC
run: |
  dotnet test ./tests/ProjectC/ProjectC.csproj -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72858310

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档