[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$fFG2xyxCOzAsY-9ug_Fdg5azNwpq8g5XhgVOw1vqgIQU":3},{"code":4,"message":5,"data":6},200,"成功",{"id":7,"createdAt":8,"title":9,"content":10,"summary":11,"image":12,"uid":13,"user":14,"categoryId":21,"category":22,"subCategoryId":24,"subCategory":25,"comments":27,"status":17,"reason":12,"notice":12,"visitCount":28,"commentCount":29,"keywords":30},67,"2024-02-02T10:15:27.668Z","iOS的单元测试","# 单元测试\n\n*   逻辑测试\n*   性能测试\n*   异步测试\n*   UI测试\n*   自动化测试\n    驱动：TDD测试驱动代码\n\n## Example 1 Normal Test\n```\n- (void)setUp {\n    // Put setup code here. This method is called before the invocation of each test method in the class.\n    \n    self.vc = [[ViewController alloc] init];\n}\n\n- (void)testPlus {\n    int num1 = 10;\n    int num2 = 20;\n    int plus = [self.vc getPlus:num1 num2:num2];\n    XCTAssertEqual(plus, 20, @\"test failed\");\n}\n```\n\n## Example 2 Async Tes\n```\n- (void)loadData:(void (^)(id))dataBlock {\n    dispatch_async(dispatch_get_global_queue(0, 0), ^{\n        [NSThread sleepForTimeInterval:2];\n        NSString *dataStr = @\"异步\";\n        dispatch_async(dispatch_get_main_queue(), ^{\n            NSLog(@\"Refresh UI\");\n            dataBlock(dataStr);\n        });\n    });\n    \n}\n\n- (void)testAsyExample {\n    // 时间 + 数据\n    XCTestExpectation *exp = [self expectationWithDescription:@\"如果不在我预期\"];\n    \n    [self.vc loadData:^(id data) {\n        XCTAssertNotNil(data, @\"为nil\");\n        [exp fulfill];\n    }];\n    [self waitForExpectationsWithTimeout:1.5 handler:^(NSError * _Nullable error) {\n        NSLog(@\"%@\", error);\n    }];\n}\n```\n\n## Example 3 Performance Test\n```\n- (void)testPerformanceExample {\n    // This is an example of a performance test case.\n    [self measureBlock:^{\n        // Put the code you want to measure the time of here.\n        \n        /**\n         性能测试\n         参照物\n         统计学\n         baseline\n         */\n        [self.vc openCamera];\n    }];\n}\n```","在iOS中如何做单元测试，这里给出几个简单的示例。","",499668042977349,{"phone":15,"userId":13,"nickName":16,"vipType":17,"avatar":18,"sign":19,"createdAt":20},"13121171998","全栈老韩",1,"https://image.xinwei.ltd/images/IMG_5430.JPG","全栈工程师，擅长iOS App开发、前端（vue、react、nuxt、小程序&Taro）开发、Flutter、React Native、后端（midwayjs、golang、express、koa）开发、docker容器、seo优化等。","2024-01-01T16:14:30.305Z",2,{"id":21,"name":23},"IT技术",3,{"id":24,"name":26,"parentId":21},"iOS",[],31,0,"ios unitest,unitest,ios测试,ios开发"]