For example, Cocoa uses the target-action pattern for controls. When you create an
NSButton you can specify which object to send a message to when it's clicked — the target — and what message to send — the action.You can trust that when you click the button, Cocoa will cause the action message to be sent to the target object so long as they have been properly specified. Therefore you probably don't need to write a unit test that simulates clicking on the button. However, you should verify that your button has had its target and action properly specified, and you can write a test for this.
You can also apply this principal in your own code. Let's say you're implementing a new type of control that also has to follow the target-action pattern. In the tests for your control itself, you probably will want to simulate the appropriate user-interface events and see that a testing instance of your control behaves appropriately. However, you don't need to do this in the code that uses the control — you can trust that the control behaves correctly due to the tests you wrote for the control itself, and just verify that it's been properly configured.
![[info]](http://l-stat.livejournal.com/img/userinfo.gif)
testing this one...
(Anonymous)
2007-11-21 08:26 pm (UTC)