XCode下的iOS单元测试
- (void)testSimpleFail { GHAssertTrue(NO, nil); } |
OCMockSampleTest.h #import <GHUnitIOS/GHUnit.h> @interface OCMockSampleTest : GHTestCase @end OCMockSampleTest.m #import "OCMockSampleTest.h" #import <OCMock/OCMock.h> @implementation OCMockSampleTest // simple test to ensure building, linking, // and running test case works in the project - (void)testOCMockPass { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; GHAssertEqualObjects(@"mocktest", returnValue, @"Should have returned the expected string."); } - (void)testOCMockFail { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; GHAssertEqualObjects(@"thisIsTheWrongValueToCheck", returnValue, @"Should have returned the expected string."); } @end |
- (void)testExample { STFail(@"Unit tests are not implemented yet in OCUnitProjectTests"); } |
GHUnitSampleTest.h #import <GHUnitIOS/GHUnit.h> @interface GHUnitSampleTest: GHTestCase { } @end GHUnitSampleTest.m #import "GHUnitSampleTest.h" @implementation GHUnitSampleTest - (void)testStrings { NSString *string1 = @"a string"; GHTestLog(@"I can log to the GHUnit test console: %@", string1); // Assert string1 is not NULL, with no custom error description GHAssertNotNULL(string1, nil); // Assert equal objects, add custom error description NSString *string2 = @"a string"; GHAssertEqualObjects(string1, string2, @"A custom error message. string1 should be equal to: %@.", string2); } @end |
OCMockSampleTest.h #import <GHUnitIOS/GHUnit.h> @interface OCMockSampleTest : GHTestCase @end OCMockSampleTest.m #import "OCMockSampleTest.h" #import <OCMock/OCMock.h> @implementation OCMockSampleTest // simple test to ensure building, linking, // and running test case works in the project - (void)testOCMockPass { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; GHAssertEqualObjects(@"mocktest", returnValue, @"Should have returned the expected string."); } - (void)testOCMockFail { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; GHAssertEqualObjects(@"thisIsTheWrongValueToCheck", returnValue, @"Should have returned the expected string."); } @end |
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Snapchat开始支持在视频中贴emoji表情
据外媒报道,静止、一成不变的emoji表情将很快在Snapchat上成为历史。现在,Android版Snapchat开始支持为视频中的某个特定对象贴上emoji表情的功能,即emoji将也能跟随所贴对象移动、旋转、放大缩小了。iOS用户不用着急,Snapchat承诺会在未来几周内也向他们推送这项功能。 据悉,Snapchat在这次更新中对聊天(Chat)功能的界面进行了重新设计,它新增了200多张贴纸,另外用户还能更加轻松地在上面拨打视频电话了--因为他们不再需要一直按着按钮保持通话了。此外,照片和视频都能在聊天功能下发送以及在视频电话中分享,用户则还能在好友未接到其打出的电话时留下视频语音留言。 本文转自d1net(转载)
- 下一篇
用python做自动化测试—Monkeyrunner问题的解决方案
Monkeyrunner为Andriod SDK 嫡亲的 测试工具,功能还是很强大的,但Andriod的测试技术发展比较晚,所以目前国内的教程和例子比较少,很多功能没有发掘出来。 Monkeyrunner的例程google下可以有很多,这里就不在重复了,下面说说大家可能遇到的几个问题,及解决方案。 1. 点击button,选择输入焦点,只能靠坐标来定位,一旦换手机,坐标完全失效了。 解决方案a: 通过device.getProperty("display.width"),device.getProperty("display.height")得到你调试手机的像素,在新的手机中,通过这2个参数的比例关系,可以得到在新手机的X,Y坐标点。 解决方案b:通过view server查询ID来定位,这种方法是最好的,肯定不会错。但很多手机上view server不 工作,即使被rooted了(可以通过hierarchyviewer.bat来确认view server是否工作). 破解过程有点下复杂,大家可以参考这里,还是可以破解的。http://blog.apkudo.com/tag/view...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- SpringBoot2整合Redis,开启缓存,提高访问速度
- CentOS8编译安装MySQL8.0.19
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7,8上快速安装Gitea,搭建Git服务器
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- Windows10,CentOS7,CentOS8安装Nodejs环境