关闭

OCUnit单元测试学习

发表于:2014-3-13 11:10

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:whj    来源:51Testing软件测试网采编

  2、循环测试实例方法(多个测试用例);
- (int)getValue{
static int value = 1;
value +=1;
NSLog(@"test 2 value:%d",value);
return value;
}
- (void)doTest:(int)value expect:(int)expect{
int doubleValue = [self.viewController doubleValue:value];
XCTAssertTrue(expect == doubleValue, @"期望值:%d,实际值:%d",expect,doubleValue);
}
- (void)testDoubleValue{
for (int count = 0; count < 10; count++) {
int value = [self getValue];
[self doTest:value expect:value*2];
}
}
  3、测试异步调用(UI操作、网络等操作);
- (void)testInput{
ZYAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
UIWindow *window = delegate.window;
viewController = (ZYViewController*)window.rootViewController;
viewController.textField.placeholder = @"请输入...";
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
XCTAssertTrue([viewController.textField.text length]>0, @"textField had not input");
}
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号