测试随机崩溃waitForExpectation,总是如果我满足期望dispatch_after.
它发生在objective-c和swift中.
完全随机,有时它有时不起作用.有谁有想法吗?(我在MacMini上使用CMD + U运行它,但我也尝试使用MBP Retina,结果相同)
示例代码:
func testBarcodeNotFound() {
let exp = self.expectationWithDescription("store loading")
OHHTTPStubs.stubRequestsPassingTest({ (request:NSURLRequest!) -> Bool in
if request.URL.absoluteString == nil {
return false
}
return request.URL.absoluteString!.hasSuffix("/products/barcode/1422/")
}, withStubResponse: { (request:NSURLRequest!) -> OHHTTPStubsResponse! in
let data = "".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
return OHHTTPStubsResponse(data: data, statusCode: 404, headers: ["Content-Type":"application/json"])
})
self.productsVC.scanningVC.successScan("1422", "EAN13")
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in
exp.fulfill()
}
self.waitForExpectationsWithTimeout(1, handler: nil)
XCTAssertTrue(self.delegateForProductsVC.barcodeNotFoundCalled)
}
Run Code Online (Sandbox Code Playgroud)
并回溯
(lldb) bt
* thread #1: …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
dispatch_async(dispatch_get_main_queue(), ^{
if (self.adAppearBlockIsAnimated) {
[UIView animateWithDuration:kAnimationTime animations:^{
self.adAppearBlock();
}];
}
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,Uncrustify让它看起来像:
dispatch_async(dispatch_get_main_queue(), ^{
if (self.adAppearBlockIsAnimated) {
[UIView animateWithDuration:kAnimationTime animations:^{
self.adAppearBlock();
}];
}
});
Run Code Online (Sandbox Code Playgroud)
我的配置:
indent_oc_block=true
indent_oc_block_msg = 0
Run Code Online (Sandbox Code Playgroud)
有谁知道如何使它看起来正常吗?嵌套块中没有额外的空格.
编辑:我现在无法发表评论,我正在使用xCode.
整个构建正在编译好一些警告,一切似乎都有效.
但是当我运行测试时,我得到:
2015-05-13 10:38:52.450 InventorumNativeDevFast [38263:179686]***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'路径上似乎没有有效的编译故事板'/ Users/jenkins /Library/Developer/CoreSimulator/Devices/4F58B740-983B-4E49-B3DC-4DD507DFF6DF/data/Containers/Bundle/Application/C49589F2-C9B5-4AEB-B12E-E57EE745C47C/InventorumNativeDevFast.app/Base.lproj/Inventory_iPad.storyboardc ''
我缩小了日志以编译这个特定的故事板.
mini:Base.lproj jenkins$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool --target-device ipad --errors --warnings --notices --companion-strings-file de:/Users/jenkins/workspace/inventorum_frontend_ios_native_unit_tests_beta/InventorumNative/de.lproj/Inventory_iPad.strings --module Inventorum --minimum-deployment-target 7.0 --output-partial-info-plist /Users/jenkins/Library/Developer/Xcode/DerivedData/InventorumNative-adclekctloebjhfbehzjndtvdwbe/Build/Intermediates/InventorumNative.build/Debug-iphonesimulator/InventorumNativeDevFast.build/Inventory_iPad-SBPartialInfo.plist --auto-activate-custom-fonts --output-format human-readable-text --compilation-directory /Users/jenkins/Library/Developer/Xcode/DerivedData/InventorumNative-adclekctloebjhfbehzjndtvdwbe/Build/Products/Debug-iphonesimulator/InventorumNativeDevFast.app/Base.lproj /Users/jenkins/workspace/inventorum_frontend_ios_native_unit_tests_beta/InventorumNative/Base.lproj/Inventory_iPad.storyboard
nwi_state: registration failed (1000000)
2015-05-13 10:45:39.934 Interface Builder Cocoa Touch Tool[38344:184492] ***storageTaskManagerExistsWithIdentifier:withIdentifier failed: Error Domain=NSCocoaErrorDomain Code=4099 "The operation couldn’t be completed. (Cocoa error 4099.)" (The connection to service named com.apple.nsurlstorage-cache was invalidated.) UserInfo=0x7fb03493a480 {NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
NSDebugDescription = "The connection to service …Run Code Online (Sandbox Code Playgroud) ios ×3
objective-c ×3
swift ×2
code-cleanup ×1
crash ×1
formatting ×1
storyboard ×1
uncrustify ×1
xcode ×1
xctest ×1