Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It depends on what you mean by "testing Cocoa GUIs."</p> <p>If you want tools like the old <a href="http://www.mactech.com/articles/mactech/Vol.12/12.09/UsingVirtualUser/index.html" rel="noreferrer" title="Using Virtual User">Virtual User</a> tool included with MPW, then those are few &amp; far between; you'll be looking at tools like Squish and Eggplant. </p> <p>If you want to write <em>unit tests</em> for your application's human interface, I suggest you follow a "<a href="http://eschatologist.net/blog/?p=16" rel="noreferrer" title="Trust, but verify.">trust, but verify</a>" approach where you <em>trust</em> that as long as you're making the right connections (according to your framework) that your user can interact properly with your framework. That means you can do the majority of your testing by <em>verifying</em> your model and controller code are hooked up to your views correctly.</p> <p>On my weblog, I've written a couple of examples of how to do this specifically with Cocoa, one for <a href="http://eschatologist.net/blog/?p=10" rel="noreferrer" title="Unit testing Cocoa user interfaces: Target-Action">testing user interfaces built with target-action</a>, and one for <a href="http://eschatologist.net/blog/?p=12" rel="noreferrer" title="Unit testing Cocoa user interfaces: Cocoa Bindings">testing user interfaces built with Cocoa bindings</a>. (Remember, of course, that the two technologies aren't exclusive: If you want to do drag &amp; drop in a table view managed via Cocoa bindings, you'd also have a data source and probably a delegate hooked up via target-action.)</p> <p>The thing I don't write unit tests for — generally — is the positioning or type of controls in their superview. Sometimes that is important to get and keep correct, however; in that case, I can just query the appropriate properties of the controls and verify them using the standard assertions.</p> <p>What I <strong>virtually never</strong> do is write code to "simulate events." The closest I've ever come to that is constructing a fake drag info object and passing that to an outline view data source to ensure it will deal with drags correctly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload