I have been using OCUnit for unit testing in a project. I’ve managed to do all the setup required for OCUnit in Xcode 4.2 & successfully build my test cases.
How can I control the order (priority) for a test case? I see that test cases are built in alphabetic order of their name, i.e. if I have test method testA, testB, testC, they’ll be executed in that same order.
What I need is for “testC” in the above example to be executed before “testB”, as my method has some setup for variables & preferences for “testB”, as well as core data entry, included in “testC”.
Either your make your test cases self-contained, so that they can run on their own without pre-conditions, or you name your test methods accordingly as you mentioned.
I would recommend to make them self-contained. It’s a little overhead, but you can implement reusable methods in your test case (that don’t start with
test) to make your life easier.If you want a framework with more features check out GHUnit