What is the best approach for writing unit tests for iPhone / iPad?
Asked Answered
H

2

2

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?

Hellenism answered 15/4, 2010 at 5:7 Comment(7)
saying that iphone applications are "rather small" is a bit of a generalisation wouldn't you say? Maybe the applications you develop are rather small but there some very complex applications on the appstore.Heterozygote
You should change the title if you are questioning the (your) toolkit not the method. That's why you get all those down-votes.Inseparable
@Madhup: Perhaps another question or community wiki on unit/integration/what have you testing of iphone/ipad apps would be a better approach.Chose
@ROMANARMY I think I hve got enough down votes..... ;)Hellenism
@Madhup: On this question, probably. But if you'll notice some of the answers/comments talk about various unit/integration testing approaches for iPhone/iPad development. Quick search didn't yield any similar resources on SO, so it could turn out pretty useful. The down votes you got for the original phrasing of the title/question.Chose
@ROMANARMY well i have asked a similar question #2643389 But no answers that is why i have changed the topic of this question and not asking new oneHellenism
@Brad Larson: Thanks for editing the question, would it make more sense as a CW? I'm deleting my answer since it's no longer appropriate for the question.Chose
I
6

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 individual routines do, and thus gain confidence in the correctness of your code, by writing the tests.

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

Inseparable answered 15/4, 2010 at 5:11 Comment(0)
S
6

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.

Supper answered 15/4, 2010 at 5:31 Comment(4)
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.Tyrannicide
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.Supper
That's fine, but it isn't offering anything you wouldn't get with Google Toolbox. Looking for some reason to use it instead.Tyrannicide
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.Supper

© 2022 - 2024 — McMap. All rights reserved.