2017-05-11 3 views
1

私はアプリケーションのパフォーマンスを測定するために、XCodeのXCTestCaseを使用して自動UIテストを行っています。私は現在、25 000要素のUITableを持っています。このリストをスワイプするテストを実行しようとすると、テストを終了する前に永久にクラッシュします。この時点で、アプリケーションのCPU使用率は100%になっています。XCTestCaseスナップショットのアクセシビリティ階層を無効にする

コンソールの最後の出力は次のようになります。

ため

スナップショットのアクセシビリティ階層数百の要素(許容できない)自動テストをスクロールすることができますにダウンリストを制限する場合リストは少なくとも1つのスクロールの間に約3〜4秒待ってください。

テストシナリオ:

let app = XCUIApplication(); 
app.buttons["Long list"].tap(); 

let table = app.tables.element; 
table.swipeUp(); 
table.swipeUp(); 

ので、テストを高速化する方法はありますか?おそらくアクセシビリティ階層を無効にする(テストのためにアクセシビリティラベルを使用しない)。

答えて

0

多分あなたは- (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;

#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]; 
    } 
} 
のようなAPIを使用することができます
関連する問題