????λ?????????? >> ??????????
???????Tests???鼰???
???????????? ???????[ 2017/2/4 14:39:45 ] ??????????????? ???????
/**
testLoadPersonAsync ?????????:
???????????????:??????????????????!
1.????е?:
1.1 ?? setUp --->
??? test1
?? test2
?? test3 ......
?? tearDown ???????????????????.
*/
#pragma mark - testLoadPersonAsync ?????????
- (void)testLoadPersonAsync {
//Xcode6.0??????????:
//???????"???"expectation:
XCTestExpectation *expectation = [self expectationWithDescription:@"?????? Person"] ;
[Person loadPersonAsync:^(Person *person) {
NSLog(@"-_- --> %@ <-- -_-" ?? person.name) ;
//????????:
[expectation fulfill] ;
}] ;
//????????:
//1.0f'????????????????????:
[self waitForExpectationsWithTimeout:1.0f handler:^(NSError * _Nullable error) {
NSLog(@"?????? --> error = %@ <-- ??????" ?? error) ;
}] ;
}
@end
????Person.h ???
#import <Foundation/Foundation.h>
@interface Person : NSObject
//name:
@property (nonatomic?? copy) NSString *name ;
//age:
@property (nonatomic) NSInteger age ;
//????????:
+ (instancetype)personWithDictionary:(NSDictionary *)dictionary ;
//???????????:?????????????????????? block!
//??д block?????????: void (^) (Person *person)completion ;
+ (void)loadPersonAsync:(void (^) (Person *person))completion ;
@end
????Person.m ???
#import "Person.h"
@implementation Person
+ (instancetype)personWithDictionary:(NSDictionary *)dictionary {
//[[self alloc] init] ;?????? self ?????????????????????????? person ?????????????д?????????!
Person *obj = [[self alloc] init] ;
//KVC ????:
[obj setValuesForKeysWithDictionary:dictionary] ;
//???????????????????:
if (obj.age <= 0 || obj.age > 100) {
obj.age = 0 ;
}
return obj ;
}
//д????????:???????? title : boss ???????????:
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
}
+ (void)loadPersonAsync:(void (^)(Person *))completion {
dispatch_async(dispatch_get_global_queue(0?? 0)?? ^{
[NSThread sleepForTimeInterval:1.0f] ;
Person *person = [Person personWithDictionary:@{@"name":@"lisi" ?? @"age":@20}] ;
dispatch_async(dispatch_get_main_queue()?? ^{
//?? OC ??д????????????????д?????????????ж???????????????????????:
if (completion != nil) {
//???????person ??????????:
completion(person) ;
}
}) ;
}) ;
}
@end
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
iOS???????mocha??chai??sinon??istanbul???????????????????????????????????????д?????Java????????7??????Android?????????Robolectric3.0????(?)???Kiwi?????????????????????????????????Python?????????????????????????????????????Controller????????д?????????10???????????????????Angular????????????Component??Directive??Pipe ???ServiceAndroid????????????????????????????????--Mockito??????iOS UnitTest???????Vue?????????????????
???·???
??????????????????
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????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????