Does anyone know of any xUnit testing frameworks for the Mac OS, more specifically for the iPhone OS? I've seen a couple online, google-toolbox-for-mac & objcUnit, but they don't seem to have had any development on them for a long time.
Are there any Objective-C deve开发者_如何学Clopers out there that perform unit testing and if you do what tools do you use?
- gh-unit is a great framework and is actively maintained. it has a GUI.
- ocunit is bundled with Xcode.
- XcodeUnitTestGUI which is fairly immature, but works and provides a GUI for ocunit based tests (disclaimer -- this is my project).
OCUnit (shipped with Xcode) is a full xUnit-style testing framework that is integrated with Xcode (failures show up as linked build errors) and works on the iPhone and OS X. The Google Toolbox for Mac provides additional functionality (including UI testing and gcov support) on top of OCUnit. I'm not sure where you got the idea that it's not under active development. The last change was only 4 days ago (at the time of this post). For a mock framework, check out OCMock, an OCUnit-integrated mocking library (you may find that Objective-C's dynamic nature makes unit testing in general and mocking in particular much easier than expected by those accustomed to C/C++/C#/Java).
Believe it or not, Objective-C developers do do unit testing.
UnitTest++ is a very light weight, but powerful unit testing framework that I like a lot. It's site is: http://unittest-cpp.sourceforge.net/.
I've written a blog article about integrating it into an iPhone development environment, for more information you can see here: http://acornheroes.com/?p=152
Hope this helps.
I agree that OCUnit is a great xUnit tool. Integration with Xcode is solid, and it works well with OCMock. It's also hard to overstate the value of Apple being committed to the code — there is certainly room for improvement, but it's solid and still maintained. Xcode also integrates pretty nicely with gcov
, a GNU tool for instrumenting code coverage. A few links...
- http://cocoaheads.byu.edu/resources/unit-testing-cocoa
- http://cocoaheads.byu.edu/resources/unit-testing-and-code-coverage-xcode
- http://chanson.livejournal.com/182472.html
To back up Barry, yes, lots of Objective-C developers do unit testing, including inside Apple. (Just ask @bbum about CoreData unit tests...) For examples of what you can do, feel free to raid my side project:
- http://dysart.cs.byu.edu/CHDataStructures/ (API documentation)
- http://dysart.cs.byu.edu/CHDataStructures/coverage/source/ (coverage report)
- http://dysart.cs.byu.edu/chsvn/CHDataStructures/ (browse Subversion)
精彩评论