I have not yet seen a good solution for testing modules, and I will need to find it soon, so I would like to see or get a better answer.
As @tooluser said, you could provide βniceβ layouts for UITouch objects. Since there is no open constructor for UITouch supplying βrealβ UITouch instances, it is complex and will rely on private API calls. Unfortunately, since these touches must go through the code of a framework that you don't see or control, you should hope that your layouts really match all the expected UIT behavior that they double (including any personal behavior that we can't see). It makes me nervous.
Alternatively, you can follow @Sulthan's solution and test your gesture recognizers with integration tests for the UI. This is the approach I have used so far. Use a UIAutomation or a third-party test environment, such as Frank or KIF , to generate interactions with views and to claim that gesture recognizers work as expected. This may at least allow you to test the resolver separately (even if not in the true unit test).
Usually I want to have some integration tests to make sure that the interaction between several recognizers in user views behaves correctly, so I donβt think this approach is too bad, but it would be nice to really check the recognizer development test at the unit level (for the test run time if nothing else).
source share