模擬用戶旋轉設備: - (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