为了测量应用程序的性能,我使用XCode的XCTestCase进行自动UI测试。我现在有一个包含25000个元素的UITable,当我试图运行测试时,这个列表应该是永远的,在测试完成之前,它会崩溃。目前,应用程序的CPU使用率为100%。
控制台中的最后一个输出是:
快照可访问性层次结构
当将列表限制在几百个元素(不可接受)时,自动测试至少可以滚动列表,但在每个滚动之间等待大约3-4秒。
测试场景:
let app = XCUIApplication();
app.buttons["Long list"].tap();
let table = app.tables.element;
table.swipeUp();
table.swipeUp();那么,有什么方法可以加速测试吗?可能禁用可访问性层次结构(不以任何方式在测试中使用辅助功能标签)。
发布于 2017-05-19 04:13:39
也许你可以像- (double)pressAtPoint:(struct CGPoint)arg1 forDuration:(double)arg2 liftAtPoint:(struct CGPoint)arg3 velocity:(double)arg4 orientation:(long long)arg5 name:(id)arg6 handler:(CDUnknownBlockType)arg7;一样使用api。
#ifndef XCEventGenerator_h
#define XCEventGenerator_h
typedef void (^CDUnknownBlockType)(void);
@interface XCEventGenerator : NSObject
+ (id)sharedGenerator;
// iOS 10.3 specific
- (double)forcePressAtPoint:(struct CGPoint)arg1 orientation:(long long)arg2 handler:(CDUnknownBlockType)arg3;
- (double)pressAtPoint:(struct CGPoint)arg1 forDuration:(double)arg2 orientation:(long long)arg3 handler:(CDUnknownBlockType)arg4;
- (double)pressAtPoint:(struct CGPoint)arg1 forDuration:(double)arg2 liftAtPoint:(struct CGPoint)arg3 velocity:(double)arg4 orientation:(long long)arg5 name:(id)arg6 handler:(CDUnknownBlockType)arg7;
@end
#endif /* XCEventGenerator_h */
- (void)testExample {
XCUIApplication* app = [[XCUIApplication alloc] init];
XCUICoordinate* start_coord = [app coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.3)];
XCUICoordinate* end_coord = [app coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.7)];
NSLog(@"Start sleeping");
[NSThread sleepForTimeInterval:4];
NSLog(@"end sleeping");
for(int i = 0; i < 100; i++)
{
[[XCEventGenerator sharedGenerator] pressAtPoint:start_coord.screenPoint
forDuration:0
liftAtPoint:end_coord.screenPoint
velocity:1000
orientation:0
name:@"drag"
handler:^{}];
[NSThread sleepForTimeInterval:1];
}
}https://stackoverflow.com/questions/43919350
复制相似问题