Xcode 测试失败不会失败 Github 操作管道

标签 xcode continuous-integration xctest xcodebuild github-actions

我有一个 Github Action 管道:

name: default

on: [push]

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    - name: CocoaPod Install
      run: pod install
    - name: Force xcode 11
      run: sudo xcode-select -switch /Applications/Xcode_11.1.app
    - name: Test
      run: ./pipelines.sh test
    - name: Save report
      uses: actions/upload-artifact@v1
      with:
        name: test_report
        path: ./Test

和一个脚本 shell :
function test
{
    xcodebuild \
       -workspace MyApp.xcworkspace \
       -scheme DEBUG\ -\ MyApp \
       -destination 'platform=iOS Simulator,name=iPhone 11' \
       test
}

我的问题是当我在测试失败的情况下运行我的管道时,管道被标记为 PASSED,这是一个问题......

我还检查了 faSTLane,失败的测试不会使管道失败。

当测试未通过时,如何使我的管道失败?

快车道的 Cf 截图:
enter image description here

最佳答案

您需要返回一个非零值才能使该步骤失败。
尝试将此添加到 xcodebuild命令。

xcodebuild -... || exit 1

在以下问题中,除此之外还有其他一些解决方案。
How to get the return value of xcodebuild?

更新:根据您希望后续步骤完成的评论,您可以执行以下操作。

更改您的脚本以设置包含 xcodebuild 结果的输出命令。
    xcodebuild \
       -workspace MyApp.xcworkspace \
       -scheme DEBUG\ -\ MyApp \
       -destination 'platform=iOS Simulator,name=iPhone 11' \
       test
    echo "::set-output name=result::$?"

添加 id到执行此脚本的步骤。
    - name: Test
      id: xcodebuild
      run: ./pipelines.sh test

在您的工作流程结束时,您可以检查测试是否未通过和工作流程是否失败。
      - name: Check Tests Passed
        if: steps.xcodebuild.outputs.result != 0
        run: exit 1

关于Xcode 测试失败不会失败 Github 操作管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58694624/

相关文章:

ios - 如何对 `viewDidLoad()` 进行单元测试

ios - 开发支持所有 iPhone 设备的游戏的最佳方法是什么

ios - 带有 segue 的 Xcode 6.1 按钮

git - 如何使用gradle在 Jenkins 的一个根中处理整体项目?

php - 如何配置 TFS 构建定义以实现 Windows Azure Web 角色上的 PHP 项目的持续集成?

ios - swift 太聪明?使用 XCTest 测试时检查对象类型

swift - XCode UITest 不会给 NSTextField 键盘焦点

swift - 以编程方式从 UiView 推送新 View Controller 的问题

ios - animateWithDuration 在 GMSMapView 委托(delegate)方法中不起作用

testing - 当渲染器进程消耗太多内存时 Docker 崩溃了?