How to run and debug unit tests for an iPhone application

前端 未结 2 1621
灰色年华
灰色年华 2020-12-13 07:57

NOTE: Unit testing is a lot easier to setup nowadays. This tutorial is not really relevant for Xcode version 5 and above.

It took me quite some time

相关标签:
2条回答
  • 2020-12-13 08:36

    I was able to run the test case in debugger in the following simple steps:

    1. Product > Build For > Testing
    2. Put a break point in part of the test you want to debug
    3. Product > Test

    This is on Xcode 6.0.1 and seems much more convenient than the long procedure described above.

    0 讨论(0)
  • 2020-12-13 08:46

    This post is intended as a "How-to" more than a real question. Therefore this answer is just meant to allow me to mark the "How-to" as "answered". This will probably be flagged by the community as irregular. I'm up for suggestions on where to post future "How-to" articles.

    One final note though on this topic. For those who still wonder whether writing unit tests is worth it I would definitely say Yes!

    I am currently writing an application with CoreData and retrieval of data from a web service (xml parsing). The complete model can be tested and debugged without having to:

    1. run the actual application on the simulator or device. Not having to use the device to run the tests is a huge gain of time. It's the difference between 2 minutes and 5 seconds per run.
    2. without the need to create views or controllers when testing the model. The complete development and testing can focus on the model only in the first iteration. Once the model is cleared for integration the rest of the development can follow.

    To debug the xml parsing I can simply use "hard-coded" files which I completely control.

    The crux is of course to write the tests as you implement features in the code. It really is a time saver down the line in terms of debugging of the complete application.

    Voilà, I'll leave it at that.

    0 讨论(0)
提交回复
热议问题