简单的界面设计

来源:互联网 发布:江苏卫视网络视频 编辑:程序博客网 时间:2024/05/29 04:24

UI Tests是什么?

UI Tests是一个自动测试UI与交互的Testing组件

UI Tests有什么用?

它可以通过编写代码、或者是记录开发者的操作过程并代码化,来实现自动点击某个按钮、视图,或者自动输入文字等功能。

UI Tests的重要性

在实际的开发过程中,随着项目越做越大,功能越来越多,仅仅靠人工操作的方式来覆盖所有测试用例是非常困难的,尤其是加入新功能以后,旧的功能也要重新测试一遍,这导致了测试需要花非常多的时间来进行回归测试,这里产生了大量重复的工作,而这些重复的工作有些是可以自动完成的,这时候UI Tests就可以帮助解决这个问题了。

#import <UIKit/UIKit.h>


@interface AppDelegate :UIResponder <UIApplicationDelegate>


@property (strong,nonatomic) UIWindow *window;



@end







#import "AppDelegate.h"


@interface AppDelegate ()


@end


@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    returnYES;

}








#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

}



- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}



@end







#import <UIKit/UIKit.h>

#import "AppDelegate.h"


int main(int argc,char * argv[]) {

    @autoreleasepool {

        returnUIApplicationMain(argc, argv,nil, NSStringFromClass([AppDelegateclass]));

    }

}




#import <XCTest/XCTest.h>


@interface _____Tests : XCTestCase


@end


@implementation _____Tests


- (void)setUp {

    [supersetUp];

    // Put setup code here. This method is called before the invocation of each test method in the class.

}


- (void)tearDown {

    // Put teardown code here. This method is called after the invocation of each test method in the class.

    [supertearDown];

}


- (void)testExample {

    // This is an example of a functional test case.

    // Use XCTAssert and related functions to verify your tests produce the correct results.

}


- (void)testPerformanceExample {

    // This is an example of a performance test case.

    [selfmeasureBlock:^{

        // Put the code you want to measure the time of here.

    }];

}


@end






#import <XCTest/XCTest.h>


@interface _____UITests : XCTestCase


@end


@implementation _____UITests


- (void)setUp {

    [supersetUp];

    

    // Put setup code here. This method is called before the invocation of each test method in the class.

    

    // In UI tests it is usually best to stop immediately when a failure occurs.

    self.continueAfterFailure =NO;

    // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.

    [[[XCUIApplicationalloc] init] launch];

    

    // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.

}


- (void)tearDown {

    // Put teardown code here. This method is called after the invocation of each test method in the class.

    [supertearDown];

}


- (void)testExample {

    // Use recording to get started writing UI tests.

    // Use XCTAssert and related functions to verify your tests produce the correct results.

}


@end





原创粉丝点击