ios - XCUITesting 不断使我的应用程序崩溃

标签 ios xcode crash xcode-ui-testing

我的应用程序因以下堆栈而崩溃 -

Crash

Thread 1Queue : com.apple.main-thread (serial)
#0 0x0722dd39 in ___forwarding___ ()
#1 0x0722da0e in __forwarding_prep_0___ ()
#2 0x1782b083 in -[UITableViewCellAccessibility _accessibilityChildren] ()
#3 0x1782ccd0 in -[UITableViewCellAccessibility accessibilityElementCount] ()
#4 0x1794d241 in -[NSObject(AXPrivCategory) _accessibilityHasOrderedChildren] ()
#5 0x1795a3d2 in -[NSObject(AXPrivCategory) _accessibilityFrameForSorting] ()
#6 0x1795a4ba in -[NSObject(AXPrivCategory) accessibilityCompareGeometry:] ()
#7 0x07201532 in __36-[NSArray sortedArrayUsingSelector:]_block_invoke ()
#8 0x0720150a in __56-[NSArray sortedArrayFromRange:options:usingComparator:]_block_invoke ()
#9 0x071e7ddd in __CFSimpleMergeSort ()
#10 0x071e7e13 in __CFSimpleMergeSort ()
#11 0x071e7e2c in __CFSimpleMergeSort ()
#12 0x071e7cf3 in CFSortIndexes ()
#13 0x071f364a in -[NSArray sortedArrayFromRange:options:usingComparator:] ()
#14 0x07201454 in -[NSArray sortedArrayWithOptions:usingComparator:] ()
#15 0x072013f0 in -[NSArray sortedArrayUsingSelector:] ()
#16 0x178362df in -[UIViewAccessibility _accessibilityUserTestingChildren] ()
#17 0x1796ec58 in -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingChildrenCount] ()
#18 0x17953483 in -[NSObject(AXPrivCategory) accessibilityAttributeValue:] ()
#19 0x1796f559 in -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotDescendantsWithAttributes:maxDepth:maxChildren:maxArrayCount:] ()
#20 0x17970778 in -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotWithOptions:] ()
#21 0x17951a60 in -[NSObject(AXPrivCategory) accessibilityAttributeValue:forParameter:] ()
#22 0x1793b59d in _copyParameterizedAttributeValueCallback ()
#23 0x179c9538 in _AXXMIGCopyParameterizedAttributeValue ()
#24 0x179c319a in _XCopyParameterizedAttributeValue ()
#25 0x179d24b3 in mshMIGPerform ()
#26 0x07201125 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#27 0x07201090 in __CFRunLoopDoSource1 ()
#28 0x071f6546 in __CFRunLoopRun ()
#29 0x071f5866 in CFRunLoopRunSpecific ()
#30 0x071f567b in CFRunLoopRunInMode ()
#31 0x0806a664 in GSEventRunModal ()
#32 0x0806a4a1 in GSEventRun ()
#33 0x04d52cc1 in UIApplicationMain ()
#34 0x0002dc3e in main at 
#35 0x07bbea21 in start ()
<小时/>

控制台中显示以下消息 - -[UITableTextAccessibilityElement keep]:发送到已释放实例 0x24f4db30 的消息

我的应用程序在没有 UI 测试的情况下使用时工作正常。 我尝试使用记录的 UI 来记录 UITest,但仍然面临同样的崩溃。 然后我手动编写了 UI 测试,但在我的应用程序中仍然遇到相同的崩溃。

堆栈没有显示提供任何我可以调试应用程序的信息。

对此的任何帮助表示感谢。

Sample Project - 使用以下步骤在示例项目中重现崩溃。

  • 在上面的示例项目中尝试运行 TestProjectUITests.m 中的测试 testExample。

  • 或者,尝试使用 UI Recorder 按以下步骤记录 UI 测试

    1. 在“收件人”字段中输入一些文本
    2. 点击摘要字段
    3. 在抄送字段中输入一些文本
    4. 点击密件抄送字段
    5. 在密件抄送字段中输入一些文本

最佳答案

如果您可以发布一些出现此问题的代码或示例应用程序,那么提供一些有用的建议会更容易。如果遇到僵尸,您还可以运行僵尸工具来验证对象每次释放/保留时的内存堆栈。 但是,控制台错误清楚地指向代码中的可疑 UITableView 或 UITableViewCell。您可能可以在测试期间使用的应用程序导航路径中找到它们。 我怀疑有保留属性(property),

@property(nonatomic, retain) UIView *accessibleView

在 swift 中,属性默认是强的(保留计数),

var accessibleView: UiView?

在设置 UIView 子类时定义,您可能会使用 UIAccessibilityContainer 方法将 UI 元素公开为可访问元素。似乎属性在 dealloc() 中释放,或者 View 从堆栈中弹出。 如果您可以发布一些代码,事情会更清楚。

关于ios - XCUITesting 不断使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32980219/

相关文章:

ios - 让 View 覆盖应用程序中所有其他 viewController 的正确方法是什么?

javascript - UIWebView 不使用方法 stringByEvaluatingJavaScriptFromString : 评估 java 脚本

actionscript-3 - 如何检测 Adob​​e Flash 崩溃原因?

ios - 如何在 Objective C 中将 NSArray 中的内容分成两个新的内容?

ios - 使用 AutoLayout 的 iPhone 3.5 和 iPhone 4 英寸中心按钮?

ios - 如何点击 Xcode 模拟器上的特定点

ios - 文本字段中的 swift 3 tableView 复制自身

iphone - 构建的应用程序成功,但无法在我的 iPhone 设备上启动

android - 从字符串数据的键获取 bool 数据后 SharedPreference 崩溃

c# - OpenTK 显卡在遮挡剔除期间崩溃