【问题标题】:Cannot run Xcode (7.3) UI tests in Jenkins无法在 Jenkins 中运行 Xcode (7.3) UI 测试
【发布时间】:2016-08-31 22:33:26
【问题描述】:

我正在尝试在本地计算机上运行的 Jenkins 机器上从命令行运行 Xcode UI 测试。但是,当我尝试在 Jenkins 中运行 UI 测试时,它们似乎无法在模拟器中启动应用程序。发生的情况是设备在模拟器中加载,UI 测试目标打开,屏幕变黑。然后在 30 秒内似乎什么都没有发生,直到我收到如下错误(我希望应用程序启动并开始自动化):

2016-04-22 11:44:54.549 XCTRunner[33303:299557] Running tests...
11:44:54.707 XCTRunner[33303:299590] _XCT_testBundleReadyWithProtocolVersion:minimumVersion: reply received
11:44:54.711 XCTRunner[33303:299587] _IDE_startExecutingTestPlanWithProtocolVersion:16
2016-04-22 11:45:24.730 XCTRunner[33303:299557] *** Assertion failure in void _XCTFailInCurrentTest(NSString *, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-10112/XCTestFramework/Classes/XCTestCase.m:63
2016-04-22 11:45:24.732 XCTRunner[33303:299557] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_XCTFailInCurrentTest should only be called while a test is running.
Failure description: Failed to receive completion for <XCDeviceEvent:0x7f88c85972c0 page 12 usage 64 duration 0.01s within 30.0s'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102369d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000101ddddeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000102369bea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x0000000101a27e1e -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
    4   XCTest                              0x0000000101875bbf _XCTFailInCurrentTest + 375
    5   XCTest                              0x000000010189717c -[XCUIDevice _dispatchEventWithPage:usage:duration:] + 847
    6   XCTest                              0x00000001018c2612 XCInitializeForUITesting + 575
    7   XCTest                              0x000000010186191d -[XCTestDriver _runSuite] + 141
    8   XCTest                              0x00000001018627d1 -[XCTestDriver _checkForTestManager] + 259
    9   XCTest                              0x00000001018aca9a _XCTestMain + 628
    10  CoreFoundation                      0x000000010228f2ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    11  CoreFoundation                      0x0000000102284f75 __CFRunLoopDoBlocks + 341
    12  CoreFoundation                      0x00000001022846d2 __CFRunLoopRun + 850
    13  CoreFoundation                      0x00000001022840f8 CFRunLoopRunSpecific + 488
    14  GraphicsServices                    0x0000000104424ad2 GSEventRunModal + 161
    15  UIKit                               0x000000010271ff09 UIApplicationMain + 171
    16  XCTRunner                           0x00000001017e68ad XCTRunner + 6317
    17  libdyld.dylib                       0x0000000104c4692d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Build step 'Execute shell' marked build as failure
Finished: FAILURE

是否会因为我的 Jenkins 机器在 Xcode 隐式未通过测试之前无法足够快地打开它而无法启动应用程序?或者是否有阻止应用启动的通知?

【问题讨论】:

    标签: ios xcode jenkins automation


    【解决方案1】:

    XCTest 尝试向设备发送 Home 按钮按下事件,但在 30 秒内未收到完成通知。

    我认为这与通知 UIAlertView 阻止 Home 按钮将测试目标发送到后台没有任何关系,因为根据我的经验,此类问题会引发不同的错误消息 ("Failed to background test runner within ...")。

    我不熟悉 Jenkins 解决方案,但如果您怀疑超时时间太短,您可以尝试如下更改(我发现了一些 hacky 方式)。

    将以下行添加到将在[XCTestDriver _runSuite] 之前运行的代码中(例如,添加您自己的__attribute__((constructor)) 函数并将此代码放入其中):

    extern __attribute__((weak)) void* _XCTSetEventConfirmationTimeout(NSTimeInterval);
    // Change the default 30 seconds timeout.
    long MY_NEW_EC_TIMEOUT = 120;
    NSLog(@"Trying to call _XCTSetEventConfirmationTimeout(%ld)", MY_NEW_EC_TIMEOUT);
    if (&_XCTSetEventConfirmationTimeout) {
        NSLog(@"_XCTSetEventConfirmationTimeout address found");
        _XCTSetEventConfirmationTimeout(MY_NEW_EC_TIMEOUT);
        NSLog(@"_XCTSetEventConfirmationTimeout successfully called");
    } else {
        NSLog(@"_XCTSetEventConfirmationTimeout address not found");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 2022-12-10
      • 1970-01-01
      • 2014-03-28
      • 1970-01-01
      相关资源
      最近更新 更多