LoginSignup
7
7

More than 5 years have passed since last update.

KIF2.0 で Pull To Refresh コントローラのテストをする

Posted at

引っ張って更新ができる Pull To Refresh コントローラの テストを KIF 2.0 で行います.

1. 更新対象のコントローラの accessibilityLabel に @"Pull To Refresh" を設定する.


self.refreshControl.accessibilityLabel = @"Pull To Refresh";

accessibilityLabel は 目が不自由な人のための機能をサポートするためのラベルです.
テストでコントローラを指定するときもよく使われます.

2. テストコードを書く

テストメソッド名は test から始めなければならない. (testHomeView) ので注意です.
後ろにつけた場合 (homeViewTest) ではダメでした.
interface も .mファイルに書いているため ヘッダファイルは要りません.


// HomeViewTests.m

#import <KIF.h>
#import "KIFTestCase.h"

@interface HomeViewTests : KIFTestCase
@end

@implementation HomeViewTests

-(void)testHomeView{
    [self refreshHomeView];
    [tester waitForTimeInterval:5];
}

- (void)refreshHomeView{
    [tester swipeViewWithAccessibilityLabel:@"Pull To Refresh" inDirection:KIFSwipeDirectionDown];
}

@end

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7