开发者

TDD for an OSX app

Are there any good solutions out there for TDD of a MacOSX Objective-c app?

EDIT: more info

I would really like something similar to rSp开发者_开发问答ec from the Ruby world. Is the XCode built in stuff sufficient? I have heard that it is not. I would like something that supports Mocks, Stubs, and most/all of the test conditions supplied by rSpec (or similar test conditions).


Yes, TDD is easy to do with Xcode as it includes unit testing out of the box (OCUnit was included in Xcode 2.1). See Apple's documentation and Xcode Unit Testing Guide for closer details on how to develop and run unit tests in Xcode.


There's nothing like RSpec (yet) for Objective-C, but the xUnit-style frameworks SenTest/OCUnit (included with Xcode), Google Toolbox for Mac's unit testing additions to OCUnit and GHUnit are all very good. You can do BDD-style with them as well.

If you're really committed to RSpec, you may want to investigate MacRuby. Although it may feel a little heavy in an Objective-C project, you can load your Objective-C framework(s) and run your unit tests in RSpec via MacRuby.


Here is a post about "string calculator"-kata in Objective-C.

There is UISpec (based on Rspec) for the iPhone and iCuke (based on cucumber)

Autotesting (autoiphonetest.rb) like Paul did in his his blog is interesting.
Another good post: Test Driven Development in Objective-C with MacRuby


Personally i use GHUnit, It has a cool little testing app, and supports things like Async test out of the box. Something that in the Delegate heavy world of iPhone & mac programming is invaluable.

Also it's testing methods are named very similar to that of OCUnit, so it you choose either then decide to switch it's fairly easy.


Check out this series of blog posts for a bunch of info on unit testing mac and iphone apps.

http://cocoawithlove.com/2009/12/sample-mac-application-with-complete.html

http://cocoawithlove.com/2009/12/sample-iphone-application-with-complete.html

http://cocoawithlove.com/2010/01/high-quality-in-software-development.html


If you would really like to use Ruby, then you can try my fork of Bacon (a RSpec clone) called MacBacon, which is optimized for NSRunloop based environments. None of the others are at the time of writing.

If you'd like to keep the footprint small, or are working on iOS, I also have a port of the same code, to the Nu programming language, called NuBacon.

I still need to write some introductory blog posts, but if you feel adventurous go right ahead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜