Xcode 7.3
开放式雷达:rdar://25456632
我在我的应用程序中使用字符串枚举来定义一些可访问性标识符。例如:
enum AccessibilityIds:String {
case ButtonFoo
}
我建立了一些UI测试,需要搜索控件。因此,我会做如下操作:
XCUIApplication().buttons[AccessibilityIds.ButtonFoo.rawValue]
XCode认为这是正确的,而且在该行没有显示任何错误。然而,当我编译UI测试时,会出现以下编译器错误:
Undefined symbols for architecture x86_64:
"myApp.AccessibilityIds.rawValue.getter : Swift.String", referenced from:
(extension in myAppUITests):__ObjC.XCTestCase.fooButton (myApp.AccessibilityIds) -> Swift.Bool in TestCaseExtensions.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
将UI测试目标与单元测试目标进行交叉引用(编译良好并使用枚举),我发现UI测试没有设置测试主机(Test Host)。设置后,UI测试代码现在可以编译,但是测试本身会失败,并显示一个SIGKILL错误:
testFooButton() encountered an error (Lost connection to test manager service. If you believe this error represents a bug, ...
看起来我不能在 UI 测试代码中访问枚举的原始值。有没有其他人遇到过这个问题并成功解决了?
@testable import myApp
。我也已经成功地从单元测试中访问了这个枚举,并发现在枚举上定义的任何属性或函数都是不可见的。 - drekka