Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing is Wonderful, But

I took the time to set up some Unit Tests and set up the targets in XCode, etc., and they're pretty useful for a few classes. However:

I want to test small UI pieces for which I don't want to launch the entire application. There is no concept of pass/fail: I need to "see" the pieces, and I can make dummy instances of all the relevant classes to do this. My question is: how can I set this up in XCode?

I realize I could use another XCode project for each class (or groups of classes), but that seems a bit cumbersome. Another target for each?

like image 705
Dan Rosenstark Avatar asked Sep 30 '10 20:09

Dan Rosenstark


People also ask

What makes a unit test good?

Good unit tests are independent and isolated They test one thing at a time, ideally with one assertion. They don't cause side effects. They certainly don't rely on side effects. You can run them in any order and they still pass.

What is unit testing Mcq?

A. running the system with line data by the actual user. making sure that the new programs do in fact process certain transactions according to Specifications.

What is true for unit testing?

In order to write a good unit test you should always keep a focus on simplicity. A unit test should be easy to code, easy to read, stable and as a consequence it should execute very quickly. Since you are testing a single unit your unit test should not access databases, file systems or other similar external factors.

Is unit testing worth the effort?

So, to answer your question, Unit Testing is usually worth the effort, but the amount of effort required isn't going to be the same for everybody. Unit Testing may require an enormous amount of effort if you are dealing with spaghetti code base in a company that doesn't actually value code quality.


1 Answers

I know that you're looking for an approach to testing UI components that doesn't require a fully functional application, but I've been impressed with what the new UI Automation instrument introduced in iOS 4.0 lets you do.

This instrument lets you use Javascript scripts to interactively test your application's interface, and it does so in a way that does not require checking exact pixel values or positions on a screen. It uses the built-in accessibility hooks present in the system for VoiceOver to identify and interact with components.

Using this instrument, I have been able to script tests that fully exercise my application as a user would interact with it, as well as ones that hammer on particular areas and look for subtle memory buildups.

The documentation on this part of Instruments is a little sparse, but I recently taught a class covering the subject for which the video is available on iTunes U for free (look for the Testing class in the Fall semester). My course notes (in VoodooPad format) cover this as well. I also highly recommend watching the WWDC 2010 video session 306 - "Automating User Interface Testing with Instruments".

like image 90
Brad Larson Avatar answered Sep 30 '22 21:09

Brad Larson