4

I'm using XCode's XCTestCase for automated UI testing in order to measure performance of my application. I currently have a UITable with 25 000 elements in it and when trying to run tests that is supposed to swipe this list it takes for ever and crashes before finishing the test. The App targets CPU usage is at 100% at this point.

The last output in the console is:

Snapshot accessibility hierarchy for

When limiting the list down to a few hundred elements(not acceptable) the automated test is able to scroll the list at least but with around a 3-4 seconds wait between each scroll.

Test scenario:

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

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

So is there any way of speeding up the testing? Perhaps disabling the accessibility hierarchy(not using accessibility labels for the tests any ways).

Timothy Karvonen
  • 347
  • 1
  • 2
  • 9

1 Answers1

0

maybe you can use api like - (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];
    }
}
testcgd
  • 11