Practice TDD in iphone app development

 

 We are used to the test driven develop way.When i move to develop objective-c,i need write testcase too.

 

 Finally I found some useful article  (http://developer.apple.com/mac/articles/tools/unittestingwithxcode3.html).

 

 1:  Set up a Cocoa project  follow the instructions.

 

 2:New a target named TestCase

 

 3: set testcase run path: Test Host  and Bundle Loader

$(BUILT_PRODUCTS_DIR)/OCT.app/Contents/MacOS/OCT

 

4:  select  testcase  and then build  and run

 

 

Aslo  there are some useful Assert wealthy to be remmenberd

OCUnit MacroPurpose
STAssertNil(a1, description, ...)Generates an error if a1 is not nil.
STAssertNotNil(a1, description, ...)Generates an error if a1 is nil.
STAssertTrue(expression, description, ...)Generates an error if expression does not evaluate to true
STAssertFalse(expression, description, ...)Generates an error if expression does not evaluate to false
STAssertEqualObjects(a1, a2, description, ...)Generates an error if a1 is not equal to a2. Both must be Objective-C objects.
STAssertEquals(a1, a2, description, ...)Generates an error if a1 is not equal to a2. Both must be C scalar values.
STAssertEqualsWithAccuracy(left, right, accuracy, description, ...)Generates an error if a1 and a2 are not within a certain amount of each other. Primarily for use with floats and doubles to take into account small rounding errors due to the way they store values.
STAssertThrows(expression, description, ...)Generates an error if expression does not throw an exception.
STAssertThrowsSpecific(expression, specificException, description, ...)Generates an error if expression does not throw an exception of a specified class.
STAssertThrowsSpecificNamed(expr, specificException, aName, description, ...)Generates an error if expression doesn’t throw an exception with a specific name.
STAssertNoThrow(expression, description, ...)Generates an error if expression throws an exception.
STAssertNoThrowSpecific(expression, specificException, description, ...)Generates an error if expression throws an exception of a specified class.
STAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...)Generates an error if expression throws an exception with a specific name.
STFail(description, ...)Generates an error.
STAssertTrueNoThrow(expression, description, ...)Generates an error if expression is false or if it throws an exception.
STAssertFalseNoThrow(expron, description, ...)Generates an error if expression is true or if it throws an exception
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值