Title: Ways of running quick and dirty tests in XCode4
Tags: testing;xcode4
Question: I'm trying to figure out how to run a quick and dirty test time efficiently.
Sometimes I run into a situation where I want to test a few lines of code. For example, test whether NSMutableDictionary crashes if I initWithDictionary but use nil.
Right now I create a new project and test it out.  I've also been known to just add the simple test into the main delegate (so it's the first thing loaded.)
Creating a project takes too much time and space, and editing delegate has potential of causing other problem (forgot to remove, etc), plus it requires recompiling.
Are there better alternatives to these two methods?  Something like: evaluate expression, or evaluate two lines of expression.

Here is the accepted answer: I know Dave DeLong keeps a throwaway project around specifically for things like this. Just make a new project and call it "Nothing" or something. Rather than throwing it away when you're done, just save the project. Next time you need to test some code, just open up the Nothing project and drop your code in.
Of course, this works best if you're just testing the behavior of Apple frameworks. If you need to link against your own code, a unit test target would probably be better.

Here is another answer: The best way would be to add a unit tests target to your project and create unit test cases for the code you'd like to try out.
They can even stay there in case of refactoring in project's future.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:07/08/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<testing><xcode4>', 'Title': 'Ways of running quick and dirty tests in XCode4', 'ViewCount': 32, 'id': 6627598, 'user_AboutMe': '<p>(your <em>about me</em> is not currently blank)</p>\n', 'user_AccountId': 250662.0, 'user_DisplayName': 'AWF4vk', 'user_Reputation': 5790.0, 'user_Views': 170.0, 'user_id': 527525.0}}