好吧,到目前为止,我还没能在任何测试版中运行此测试.我遇到的一些问题是在这里和这里
现在,我觉得我错过了一些东西.
到目前为止,这是我的进步


然后,我运行了这个测试.
甚至在调用测试之前,整个事情都失败了,在使用以下内容在setup()中启动应用程序之后
***断言失败 - [XCUIApplication init],/ Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-8170.3/XCTestFramework/UI Testing/XCUIApplication.m:76/Users/UserName/Documents/Projects/Testing/UiTesting/UITestingApp/UITestingApp.swift:0:错误: - [UITestingApp.UITestingApp testSimpleTap]:failed:捕获"NSInternalInconsistencyException","没有通过测试配置指定的目标应用程序路径:
testBundleURL:file:/// Users/UserName /图书馆/开发商/ CoreSimulator /设备/ E3201DC2-CAD3-48C3-95F5-15E18DCA1836 /数据/集装箱/包/应用/ 8B33FC59-FC03-41F8-BD21-43D81BA2D355/UITestingApp-Runner.app /插件/ UITestingApp.xctest /
productModuleName :( null)testsToRun:(null)reportResultsToIDE:no sessionIdentifier:<__ NSConcreteUUID 0x7f93e146c0b0> F242796B-ED26-4AA7-861A-540D2D93CB8F pathToXcodeReportingSocket:(null)disablePerformanceMetrics:no treatMissingBaselinesAsFailures:no baselineFileURL:(null)targetApplicationPath :(null)targetApplicationBundleID:(null)reportActivities:no
任何人遇到这个或对我可能缺少什么有任何建议?
注意:我确实将UI测试目标的"目标应用程序"设置为我的应用程序
更新:我注意到这适用于Xcode的所有beta/final版本 - 相应地更新了标题
我已经成功地分别使用钥匙串和钥匙串共享(在多个设备之间同步钥匙串项)来实现TouchID.当我尝试同时执行它们时,我收到错误"-50",这是无效参数.从下面的代码中,删除kSecAttrAccessControl或kSecAttrSynchronizable按预期工作.
根据我的经验(阅读 - 几天的挫折)到目前为止,并基于一些钥匙串API简化工具(如UICKeychainStore)的功能,似乎如果我使用Touch ID身份验证,钥匙串共享将无法工作,反之亦然.我正在寻找可以说明但无法找到它的Apple文档.
我已经浏览了Apple的SecItem.h页面,我找到了一个有用的信息,其中包含有关kSecAttrAccessible和kSecAttrSynchronizable的信息:"如果在OS X或iOS上都指定了这两个属性,则kSecAttrAccessible密钥的值可能只是其名称之一不会以"ThisDeviceOnly"结尾,因为那些不能同步到另一台设备."但是,我没有使用"ThisDeviceOnly"(我目前正在使用kSecAttrAccessibleAlways进行测试)
您能否指出Apple是否以及在何处记录此限制?这将有助于我记录它的记录,并继续前进.谢谢.
- (void)addKeychainItemWithIdentifier:(NSString *)identifier andData:(NSData *)data {
CFErrorRef error = NULL;
SecAccessControlRef sacObject;
sacObject = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
kSecAttrAccessibleAlways,
kSecAccessControlUserPresence, &error);
if(sacObject == NULL || error != NULL)
{
NSString *msg0 = [NSString stringWithFormat:NSLocalizedString(@"SEC_ITEM_ADD_CAN_CREATE_OBJECT", nil), error];
[self printResultWithMessage:msg0];
return;
}
NSDictionary *attributes = @{
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecValueData: data,
(__bridge id)kSecAttrAccessible:(__bridge id)kSecAttrAccessibleAlways,
(__bridge id)kSecAttrService: identifier,
(__bridge id)kSecAttrSynchronizable:(__bridge …Run Code Online (Sandbox Code Playgroud) 我\xe2\x80\x99m 在 swifts 中编写单元测试,并测试独特的工作流程。
\n\n在 methodA() 中,我使用异步方法错误地加载了对象(例如使用不正确的凭据)。也开启了期待
\n\n func methodA(withCred credential: NSURLCredential) {\n var objA = ObjectA()\n // Set objA.a, objA.b, objA.c, \n objA.credential = credential //Incorrect credential First time, Correct Credential second time \n objA.delegate = self \n expectation = expectationWithDescription(\xe2\x80\x9cAync\xe2\x80\x9d)\n objA.callAsyncMethod() //This fires successDelegate() or failureDelegate()}\nRun Code Online (Sandbox Code Playgroud)当 FailureDelegate() 被触发时,我重新加载对象,这次是正确的。为此,我需要再次调用 MethodA() (这样我就可以重用那里的所有其他内容)。
\n\nfunc failureDelegate(error: NSError!) {\n\nXCTAssertTrue(error.localizedDescription == \xe2\x80\x9cInvalid Credentials\xe2\x80\x9c)\n//Now that I\xe2\x80\x99ve verified correct error is returned, I need to reload objA\nmethodA(withCred:correctCredential) \n}\n\nfunc successDelegate(obj : ObjectA) …Run Code Online (Sandbox Code Playgroud)在委托方法中,我得到一个自定义对象类型的"结果"数组,我想循环遍历数组元素.我现在做以下,这是有效的
for result in results {
if result is XYZClass {
//This Works!
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在for循环中输入对象以避免写两行?swift允许这个吗?用于在Objective-C中相当容易地完成此操作
for (XYZClass *result in results) {
}
Run Code Online (Sandbox Code Playgroud)
但是,我没有在Swift中取得成功.我试过没有运气的显式演员.
for result as XYZClass in results {
//ERROR: Expected ‘;’ in ‘for’ statements
}
for result:AGSGPParameterValue in results {
/* ERROR: This prompts down cast as
for result:AGSGPParameterValue in results as AGSGPParameterValue { }
which in turn errors again “Type XYZClass does not conform to Sequence Type”
*/
}
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏