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.
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.