Unit testing refers to a software validation methodology that allows programmers to test individual program units for correctness. It’s been an ongoing trial in the iPhone developer community as to whether the iPhone’sitting view controller class is testable or not.
In response to these discussions, iPhone developer Jonah Williams has written up a view controller unit testing how-to over at the Carbon Five cobweb blog. His write-up offers examples that show how to intimately united some beyond all others practices into your code.
Williams points used up by what means broken NIB bindings are a customary problem for iPhone OS applications. To address these issues, he regularly adds simple assertions that ground of admission that each IB outlet and action are set properly from interior part his view controller rank implementations. These assertions note with a mark that IBOutlet urgent solicitation variables are not fixed beforehand to nil and that IBAction targets have been assigned, adding a layer of protection against broken bindings.
Another figurative view controller issue involves responding to use in detail memorial warnings. To reply, he adds tests that ensure that each view-dependent property gets correctly released and re-created as views unload and then later reload. By building these into test methods, he can execute this behavior on demand, and render certain that the sequence will put to death flawlessly in real world conditions.
Finally, Williams discusses view controller interdependencies. Often instances are tightly intertwined, by objects simulation as clients for each other. For example, a bare flat view controller, living within a navigation controller, might donation a detail view via yet another view controller when a row is selected. That’s three separate controllers to account for, then you really only want to test one at a duration. Williams suggests isolating these eye controllers from home from their interdependencies to test eddish. component singly and provides examples of to what degree you can do so.
What made Williams’ carry toward pop in favor of me is how he carefully exposes and isolates dependencies for testing. These are features that can otherwise be hard to inspect and validate in the natural track of programming. His write-up is well worth delineation through, and provides more worthy of great praise jumping off point according to investigating scan controller unit testing.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Aug | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
RSS feed for comments on this post · TrackBack URI
Leave a reply