基于 KIF 的 iOS UI 自動化測試和持續集成(5)

發表于:2017-03-10來源:美團點評技術團隊作者:美團點評技術團隊點擊數: 標簽:iOSKIF
模擬用戶旋轉設備: - (void)simulateDeviceRotationToOrientation:(UIDeviceOrientation)orientation; 對當前屏幕截圖并存儲到硬盤中:- (void)captureScreenshotWithDescription:(NSStrin
    模擬用戶旋轉設備:          - (void)simulateDeviceRotationToOrientation:(UIDeviceOrientation)orientation;
    對當前屏幕截圖并存儲到硬盤中:- (void)captureScreenshotWithDescription:(NSString *)description;
(3)用例組織

設計實現單個測試用例步驟如下:

  • a. 設置測試所需要的環境;
  • b. 測試用例的測試邏輯;
  • c. 恢復App至此次測試前狀態。

a、c步驟可用 beforeEach、afterEach 來實現,這樣保證了每個用例之間的獨立性和用例運行的穩定性。
一般來說,可將用例按功能分成若干個用例集,每個用例集按校驗點或者功能點分成若干個用例,這樣方便測試用例的管理和維護。 某些含有耗費時間多、耗費資源多的公共操作的用例可以集合成一個用例集,在用例集運行前統一執行。設計實現用例集步驟如下:

  • a. 設置用例集需要的環境、公共操作;
  • b. 設計各個用例;
  • c. 恢復 App 至用例集測試的初始狀態。

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

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97