views:

462

answers:

3

I am developing an iPad application. I'm not sure if I should write unit tests for this application, and if so, how I should go about writing them.

What would you suggest as the best approach to writing unit tests for iPhone / iPad?

+5  A: 

You will write the test once, but run it many times as your application evolves.

If the tests pass, you know you didn't break anything. If the tests fail, you know where to fix. If the tests pass and the application fails, you know you need more tests.

  • In the long run writing the test will SAVE time.
  • In the short run you can validate you know what your indiv routines do, and thus gain confidence in the correctness of your code, by writng the tests.

Regardless what OS/platform your application targets, regardless of what size it has today ..

lexu
+5  A: 

Ok, there are two questions being raised here:

  1. Is unit testing worth it?

Answer: Definitely. I cannot count the times it has saved me hours of pain and suffering.

  1. What's the best way to unit test in the iPhone/iPad environment?

Answer: for myself I skipped sen and moved onto GHUnit and OCMock. GHUnit allows in simulator testing and debugging where as sen doesn't. This alone makes it a better proposition for iPhone/iPad development.

Derek Clarkson
+1 for suggesting alternative testing frameworks
R0MANARMY
Do you actually find GHUnit useful? I usually want to run a test in isolation (why I looked at it). However, deploying to the simulator or app takes longer than running all my tests.
Ty
Yes. I prefer to run tests on the simulator because I can be assured that I have not accidentally include illegal code. Once loaded, I can run a test in isolation using the GHUnit iphone UI to filter out other tests based on name. It's also good because once you have a success you can just enable all the tests to check that nothing else has broken. Generally I'm not happy until all tests are green.
Derek Clarkson
That's fine, but it isn't offering anything you wouldn't get with Google Toolbox. Looking for some reason to use it instead.
Ty
Can't give you one :-) I haven't used the google toolbox so i don't know how good it is. Would be interested in any feedback you might give on it.
Derek Clarkson
+5  A: 

Great post by Matt Gallagher on this exact topic

Ty
+1 thanks for that link!
lexu
@lexu I think the question title is correct now ???
Madhup