Ios 使用Xcode 7.2录制时,XUITest崩溃
我正在试验新的iOS用户界面测试框架,使用Xcode 7.2 我学习了一些教程,观看了苹果公司的演示视频,并试图录制一些测试案例。当目标是“模拟器”时,第一次测试成功。当我试图在一台真正的设备上重复这些步骤时,Xcode在启动应用程序后立即崩溃。我使用了苹果的演示应用程序,以便开始使用一些简单且“经过验证”的东西 下面是一个简单的测试类:Ios 使用Xcode 7.2录制时,XUITest崩溃,ios,iphone,xcode,xcode-ui-testing,Ios,Iphone,Xcode,Xcode Ui Testing,我正在试验新的iOS用户界面测试框架,使用Xcode 7.2 我学习了一些教程,观看了苹果公司的演示视频,并试图录制一些测试案例。当目标是“模拟器”时,第一次测试成功。当我试图在一台真正的设备上重复这些步骤时,Xcode在启动应用程序后立即崩溃。我使用了苹果的演示应用程序,以便开始使用一些简单且“经过验证”的东西 下面是一个简单的测试类: #import <XCTest/XCTest.h> @interface RecipesUITests : XCTestCase @end
#import <XCTest/XCTest.h>
@interface RecipesUITests : XCTestCase
@end
@implementation RecipesUITests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
self.continueAfterFailure = NO;
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
[[[XCUIApplication alloc] init] launch];
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
XCUIApplication *app = [[XCUIApplication alloc] init];
[app.navigationBars[@"Recipes"].buttons[@"Add"] tap];
[app.textFields[@"Recipe Name"] typeText:@"Lef"];
[app.navigationBars[@"Add Recipe"].buttons[@"Save"] tap];
XCUIElementQuery *tablesQuery = app.tables;
XCUIElement *descriptionTextField = tablesQuery.textFields[@"Description"];
[descriptionTextField tap];
//[descriptionTextField tap];
//[descriptionTextField tap];
XCUIElement *lefNavigationBar = app.navigationBars[@"Lef"];
[lefNavigationBar.buttons[@"Edit"] tap];
XCUIElement *overviewTextField = tablesQuery.textFields[@"Overview"];
[overviewTextField tap];
//[overviewTextField typeText:@"Lef2"];
[lefNavigationBar.buttons[@"Done"] tap];
[lefNavigationBar.buttons[@"Recipes"] tap];
}
#导入
@接口配方测试:XCTestCase
@结束
@实现菜谱测试
-(无效)设置{
[超级设置];
//将设置代码放在这里。在调用类中的每个测试方法之前调用此方法。
//在UI测试中,通常最好在出现故障时立即停止。
self.continueAfterFailure=否;
//UI测试必须启动他们测试的应用程序。在安装程序中执行此操作将确保每个测试方法都会启动。
[[XCUIApplication alloc]init]launch];
//在UI测试中,在测试运行之前设置测试所需的初始状态(如界面方向)非常重要。设置方法是一个很好的方法。
}
-(无效)拆卸{
//将拆卸代码放在这里。该方法在调用类中的每个测试方法后调用。
[超级撕裂];
}
-(无效)测试示例{
//使用录制开始编写UI测试。
//使用XCTAssert和相关函数验证测试是否产生正确的结果。
XCUIApplication*app=[[XCUIApplication alloc]init];
[应用程序导航栏[@“食谱”]。按钮[@“添加”]点击];
[app.textFields[@“Recipe Name”]typeText:@“Lef”];
[应用程序导航栏[@“添加配方”]。按钮[@“保存”]点击];
xguielementquery*tablesQuery=app.tables;
XUIElement*descriptionTextField=tablesQuery.textFields[@“Description”];
[描述文本字段点击];
//[描述文本字段点击];
//[描述文本字段点击];
XUIElement*lefNavigationBar=app.navigationBars[@“Lef”];
[lefNavigationBar.按钮[@“编辑”]点击];
XUIElement*overviewTextField=tablesQuery.textFields[@“概述”];
[概览文本字段点击];
//[概览文本字段类型文本:@“Lef2”];
[lefNavigationBar.按钮[@“完成”]点击];
[lefNavigationBar.按钮[@“食谱”]点击];
}
这是一个已知的问题吗?你知道如何调试这个问题吗?我是否需要“以某种方式”启用设备
更新#1
当我试图在设备中运行测试用例时,我在Xcode中收到一些日志
2016-01-19 13:18:36.772 XCTRunner[9331:2287347] Running tests...
2016-01-19 13:18:36.776 XCTRunner[9331:2287347] Looking for test bundles in /var/mobile/Containers/Bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/RecipesUITests-Runner.app/PlugIns
2016-01-19 13:18:36.778 XCTRunner[9331:2287347] Found test bundle at /var/mobile/Containers/Bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/RecipesUITests-Runner.app/PlugIns/RecipesUITests.xctest
2016-01-19 13:18:36.780 XCTRunner[9331:2287347] Looking for configurations in /var/mobile/Containers/Bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/RecipesUITests-Runner.app/PlugIns/RecipesUITests.xctest
2016-01-19 13:18:36.784 XCTRunner[9331:2287347] Found configuration <XCTestConfiguration: 0x145e317d0>
testBundleURL:file:///Users/unifyit/Downloads/iPhoneCoreDataRecipes_3/Build/Products/Debug-iphoneos/RecipesUITests-Runner.app/PlugIns/RecipesUITests.xctest/
productModuleName:RecipesUITests
testsToSkip:(null)
testsToRun:RecipesUITests/testExample
reportResultsToIDE:YES
sessionIdentifier:<__NSConcreteUUID 0x145e235a0> DD878763-999D-467F-968D-599B82EC5651
pathToXcodeReportingSocket:(null)
disablePerformanceMetrics:no
treatMissingBaselinesAsFailures:no
baselineFileURL:(null)
targetApplicationPath:/Users/unifyit/Downloads/iPhoneCoreDataRecipes_3/Build/Products/Debug-iphoneos/Recipes.app
targetApplicationBundleID:com.example.apple-samplecode.Recipes
reportActivities:YES
testsMustRunOnMainThread:YES
***** Begin XCTest Status Log *****
***** End XCTest Status Log *****
2016-01-19 13:18:36.772 XCTRunner[9331:2287347]运行测试。。。
2016-01-19 13:18:36.776 XCTRunner[9331:2287347]正在/var/mobile/Containers/Bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/recipiesuitests-Runner.app/PlugIns中寻找测试包
2016-01-19 13:18:36.778 XCTRunner[9331:2287347]在/var/mobile/Containers/bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/recipuitests-Runner.app/PlugIns/recipuitests.xctest找到了测试包
2016-01-19 13:18:36.780 XCTRunner[9331:2287347]正在/var/mobile/Containers/Bundle/Application/42229178-A3D8-4BB1-A4CD-7E2FC28E90F9/recipuitests-Runner.app/PlugIns/recipuitests.xctest中查找配置
2016-01-19 13:18:36.784 XCTRunner[9331:2287347]找到了配置
testBundleURL:file:///Users/unifyit/Downloads/iPhoneCoreDataRecipes_3/Build/Products/Debug-iphoneos/RecipesUITests-Runner.app/PlugIns/RecipesUITests.xctest/
productModuleName:RecipesUITests
testsToSkip:(空)
testsToRun:RecipesUITests/testExample
ReportResultsToId:是
会话标识符:DD878763-999D-467F-968D-599B82EC5651
pathToXcodeReportingSocket:(空)
失效性能指标:否
处理丢失基线失败:否
baselineFileURL:(空)
targetApplicationPath:/Users/unifyit/Downloads/iPhoneCoreDataRecipes\u 3/Build/Products/Debug iphoneos/Recipes.app
targetApplicationBundleID:com.example.apple-samplecode.Recipes
报告活动:是
TestsMustrunMainThread:是
*****开始测试状态日志*****
*****结束测试状态日志*****
看起来什么都没有发生,没有执行测试用例,Xcode试图加载应用程序,但它显示了一个黑屏
此外,当我试图重新编码Xcode时,会出现以下崩溃:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
ProductBuildVersion: 7C68
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-9548/IDEKit/Testing/IDEUIRecordingManager.m:429
Details: (result) should not be nil.
Object: <IDEUIRecordingManager: 0x7fb40190c640>
Method: -_workspaceTabController
Thread: <NSThread: 0x7fb3fb519b00>{number = 1, name = main}
Hints: None
Backtrace:
0 0x0000000103e541fa -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
1 0x00000001029e4761 _DVTAssertionHandler (in DVTFoundation)
2 0x00000001029e4978 _DVTAssertionFailureHandler (in DVTFoundation)
3 0x0000000103f3256b -[IDEUIRecordingManager _workspaceTabController] (in IDEKit)
4 0x0000000103f33433 __94-[IDEUIRecordingManager _startRecordingWithLaunchSession:alwaysAskForAPIAccess:reservedNames:]_block_invoke_2 (in IDEKit)
5 0x0000000102a20a04 __DVTDispatchAsync_block_invoke (in DVTFoundation)
6 0x00007fff8c97d8f5 _dispatch_call_block_and_release (in libdispatch.dylib)
7 0x00007fff8c9723c3 _dispatch_client_callout (in libdispatch.dylib)
8 0x00007fff8c985c1b _dispatch_main_queue_callback_4CF (in libdispatch.dylib)
9 0x00007fff986ac999 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation)
10 0x00007fff9866b9cd __CFRunLoopRun (in CoreFoundation)
11 0x00007fff9866afc8 CFRunLoopRunSpecific (in CoreFoundation)
12 0x00007fff8a5ead55 RunCurrentEventLoopInMode (in HIToolbox)
13 0x00007fff8a5eab8f ReceiveNextEventCommon (in HIToolbox)
14 0x00007fff8a5ea9cf _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
15 0x00007fff93319d96 _DPSNextEvent (in AppKit)
16 0x00007fff933191c5 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit)
17 0x0000000102fc00c2 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit)
18 0x00007fff9330dd28 -[NSApplication run] (in AppKit)
19 0x00007fff932d6fbe NSApplicationMain (in AppKit)
20 0x00007fff8fec85ad start (in libdyld.dylib)
abort() called
崩溃线程:0调度队列:com.apple.main-Thread
异常类型:EXC_崩溃(SIGABRT)
异常代码:0x0000000000,0x0000000000000000
例外说明:EXC_尸体通知
特定于应用程序的信息:
ProductBuildVersion:7C68
/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-9548/IDEKit/Testing/IDEUIRecordingManager.m:429中的断言失败
详细信息:(结果)不应为零。
对象:
方法:-\u工作空间选项卡控制器
线程:{number=1,name=main}
提示:无
回溯:
0 0x0000000103e541fa-[IDEAssertionHandler handleFailureInMethod:对象:文件名:行号:断言签名:消息格式:参数:](在IDEKit中)
1 0x00000001029e4761\u DVTAssertionHandler(位于DVT地基中)
2 0x00000001029e4978_DVTAssertionFailureHandler(在DVTFoundation中)
3 0x0000000103f3256b-[IDEUIRecordingManager\u workspaceTabController](在IDEKit中)
4 0x0000000103f33433 \uuu 94-[IDEUIRecordingManager\u StartRecording with LaunchSession:alwaysAskForAPIAccess:reservedNames:][u block\u invoke\u 2(在IDEKit中)
5 0x0000000102a20a04\uU DVTDispatchAsync\u块\u调用(在DVTFoundation中)
6 0x00007fff8c97d8f5调度调用块和释放(在libdispatch.dylib中)
7 0x00007fff8c9723c3调度客户端调用(在libdispatch.dylib中)
8 0x00007fff8c985c1b_调度_主队列_回调_4CF(在libdispatch.dylib中)
9 0x00007fff986ac999 \uuuu CFRUNLOOP \uu正在维护\uu MAIN \uu DISPATC