模拟用户旋转设备: - (void)simulateDeviceRotationToOrientation:(UIDeviceOrientation)orientation;
对当前屏幕截图并存储到硬盘中:- (void)captureScreenshotWithDescription:(NSString *)description;
设计实现单个测试用例步骤如下:
a、c步骤可用 beforeEach、afterEach 来实现,这样保证了每个用例之间的独立性和用例运行的稳定性。
一般来说,可将用例按功能分成若干个用例集,每个用例集按校验点或者功能点分成若干个用例,这样方便测试用例的管理和维护。 某些含有耗费时间多、耗费资源多的公共操作的用例可以集合成一个用例集,在用例集运行前统一执行。设计实现用例集步骤如下:
a、c步骤可用 beforeAll、afterAll 来实现,下图展示了一个用例集的书写示例:
#import "TimerTests.h"
#import "KIFUITestActor+AccessibilityLabelAddition.h"
#import "KIFUITestActor+IdentifierAdditions.h"
#import "KIFUITestActor+TimerAdditions.h"
@implementation TimerTests
- (void)beforeAll
{
[tester setDebugModel];
}
- (void)afterAll
{
[tester resetDebugModel];
[tester clearHistory];
}
- (void)beforeEach
{
[tester setDebugModel];
}
- (void)afterEach
{
[tester clearParams];
}
- (void)testNameedTask
{
[tester enterText:@"myTask" intoViewWithAccessibilityLabel:@"Task Name Input"];
[tester enterWorktime:10 Breaktime:4 Repetitions:5];
[tester tapViewWithAccessibilityLabel:@"Start Working"];
[tester waitForViewWithAccessibilityLabel:@"myTask"];
[tester waitForViewWithAccessibilityLabel:@"Start Working"];
}
- (void)testnoNameTask
{
[tester enterWorktime:10 Breaktime:4 Repetitions:5];
[tester tapViewWithAccessibilityLabel:@"Start Working"];
[tester waitForViewWithAccessibilityLabel:@"myTask"];
[tester waitForViewWithAccessibilityLabel:@"Start Working"];
}
- (void)testPresetTask
{
[tester tapViewWithAccessibilityLabel:@"Presets"];
[tester tapRowAtIndexPath:@"Classic" inTableViewWithAccessibilityIdentifier:@"Presets List"];
[tester tapViewWithAccessibilityLabel:@"Start Working"];
[tester waitForViewWithAccessibilityLabel:@"myTask"];
[tester waitForViewWithAccessibilityLabel:@"Start Working"];
}
@end
原文转自:https://zhuanlan.zhihu.com/p/22283843