iOS UI???????????
???????????????? ???????[ 2017/5/8 10:59:18 ] ??????????????? ?????????
???????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????80????????????????????????????????????????????????????????????????????????????????????????????A4?????????????????μ???????????????????????????????????????????????????
?????????????2?????????????????????????′??????????????UI???????????????????????????????
????UI Tests
????IOS??UI???????????????????????????????UI Tests??Xcode7????????UI??????????????????apple?????????????????????????????????д?????????????????????????????????????????????????????????????????????????????
??????÷???
????· ???UI Tests
?????????????????????????????????Include UI Tests?????С?
??
?????UI Tests
????????????????????????????????????target???????UI Tests??
????
???target
????
???target
????????????????л????xxxxUITests.m????????UI Tests?????????
????
???
????· ????????
????????й????????????????ú????????????UI Test????????????????????????????????????2????????- (void)setUp ??- (void)tearDown ???????????????????????????á????????Щ?????????????????д???????ɡ??????
??????????????????UI?????????????????????????????????????????????
????· ????
?????????????????ж????????????????????????????о??Щ?????????
????XCTFail(format…) ???????????????
????XCTAssertNil(a1?? format...)????ж??a1???????????????????
????XCTAssertNotNil(a1?? format…)??????ж??a1?????????????????????
????XCTAssert(expression?? format...)??expression????TRUE??????
????XCTAssertTrue(expression?? format...)??expression????TRUE??????
????XCTAssertFalse(expression?? format...)??expression????False??????
????XCTAssertEqualObjects(a1?? a2?? format...)?ж?????[a1 isEqual:a2]??TRUE????????????????????????????
????XCTAssertNotEqualObjects(a1?? a2?? format...)?ж?????[a1 isEqual:a2]??False??????
????XCTAssertEqual(a1?? a2?? format...)?ж???????a1??a2?? C??????????????????????????????????NSString????????
????XCTAssertNotEqual(a1?? a2?? format...)?ж???????a1??a2?? C???????????????????????????
????XCTAssertEqualWithAccuracy(a1?? a2?? accuracy?? format...)?ж???????double??float?????????????Χ?????????Χ??+/-accuracy??????????????????
????XCTAssertNotEqualWithAccuracy(a1?? a2?? accuracy?? format...) ?ж???????double??float?????????????Χ?????????Χ????????????????
????XCTAssertThrows(expression?? format...)?????????expression??????????????????????????????
????XCTAssertThrowsSpecific(expression?? specificException?? format...) ?????????expression????specificException??????????????????????????????????????
????XCTAssertThrowsSpecificNamed(expression?? specificException?? exception_name?? format...)?????????expression????????????????????????????????????????????
????XCTAssertNoThrow(expression?? format…)?????????expression??з??????????????
????XCTAssertNoThrowSpecific(expression?? specificException?? format...)?????????expression??з???????????????????????????????????????????
????XCTAssertNoThrowSpecificNamed(expression?? specificException?? exception_name?? format...)?????????expression??з?????????????????????????????????????????
????· XCTest UI Testing API
???????д?ò???????????????????UI Test??API????????XCUIApplication??XCUIElement??XCUIElementQuery??
????XCUIApplication
???????????????????????????????????????????????????в??????????ζ????????????????????Щ???????????????????????????????????????????????????Щ?????????????2????????
????- (void)launch;//???????
????- (void)terminate;//???????
????XCUIElement
???????NSObject?????Э??XCUIElementAttributes?? XCUIElementTypeQueryProvider
?????????????????UI????????UIView??UIButton??UITestField???
?????????????
????- (BOOL)exists;//?ж???????????
????- (XCUIElementQuery *)descendantsMatchingType:(XCUIElementType)type;//?????????????????????????
????- (XCUIElementQuery *)childrenMatchingType:(XCUIElementType)type;//??????????????????????????????
????//????????
????- (void)tap;//???????????testField??y???
????- (void)doubleTap;//???
????- (void)swipeUp;//pan????
????- (void)typeText:(NSString *)text;//????????
????- (void)pressForDuration:(NSTimeInterval)duration;//????
????· ?????????
????Xcode???????????????????????????????????????????????????????????????????????????
????
??????
????????????????????????????????????????
????XCUIApplication *app = [[XCUIApplication alloc] init];
????XCUIElement *element = [[[[app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element;
????[element tap];
????????????????????????????????????????????????????????????????????????????????????ο??£????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11