ios - 使用 Travis 进行 Swift CI 测试 - 测试运行器在开始测试执行之前退出

标签 ios swift xcode continuous-integration travis-ci

我最近开始实现 Travis,但我无法让它工作。 当我在本地运行测试时,它们成功了。

任何人都可以帮助我如何让它正常工作吗?

.travis.yml

language: swift
osx_image: xcode10.1
script:
  - xcodebuild -scheme sample -workspace sample.xcodeproj -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' build test

样本测试

class sampleTests: XCTestCase {

    func testThis() {
        XCTAssertTrue(true)
    }
}

错误:

2018-12-09 12:12:27.188 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 111.527 elapsed -- Testing started completed.
2018-12-09 12:12:27.188 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2018-12-09 12:12:27.189 xcodebuild[2161:5999] [MT] IDETestOperationsObserverDebug: 111.527 sec, +111.527 sec -- end
2018-12-09 12:12:27.190 xcodebuild[2161:5999] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted, NSUnderlyingError=0x7f981ebb72f0 {Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Test runner exited before starting test execution." UserInfo={NSLocalizedDescription=Test runner exited before starting test execution., NSLocalizedRecoverySuggestion=If you believe this error represents a bug, please attach the result bundle at /Users/travis/Library/Developer/Xcode/DerivedData/sample-dxurjdnpbvvpbicqtjbvdmsoceyy/Logs/Test/Test-sample-2018.12.09_12-10-05-+0000.xcresult}}}
Testing failed:
    sample.app (2474) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: Test runner exited before starting test execution.))
** TEST FAILED **
The command "xcodebuild -scheme sample -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' test" exited with 65.
Done. Your build exited with 1.

最佳答案

Xcode 10 中引入的新构建系统的 UI 测试存在一些问题。您应该添加 -UseModernBuildSystem=NO

我使用的完整脚本是:

- xcodebuild -workspace sample.xcworkspace -scheme sample -sdk iphonesimulator12.1 -destination "platform=iOS Simulator,OS=12.1,name=iPhone Xs Max" -UseModernBuildSystem=NO test | xcpretty --test --color; test ${PIPESTATUS[0]} -eq 0

请注意,我还使用 xcpretty,并使用一些参数来确保日志不会变得冗长。最后一部分是确保在测试失败时构建失败。

希望对您有所帮助!

关于ios - 使用 Travis 进行 Swift CI 测试 - 测试运行器在开始测试执行之前退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53692264/

相关文章:

html - Mathjax 的 iOS Swift 语法

ios - CAayer - (void)drawInContext :(CGContextRef)ctx is never called

ios - 检查LocalAuthentication中的错误类型

ios - 将单元格信息从一个 View Controller 发送到另一个 Swift 和 Parse

swift - 如何快速裁剪所选区域的视频帧大小?

ios - 获取对象并将其分类为多个部分

ios - 如何在 Swift 中为 UIImageView 对象分配一个 Action

ios - 不建议颜色文字 - Xcode 9

arrays - 无法使用 Swift 在 Xcode 中的类中创建数组

xcode git 无法从远程存储库中提取更改