Unfortunately, you are trying to test a framework class that was not written for testing, and therefore does not reveal the state you want to check. This makes it difficult to claim that there are pairs of target actions that you want to test. In this case, I have three options that you can use, none of which are a great solution:
Perhaps you can subclass UIGestureRecognizer, override target action methods to save registered pairs in a collection, which you can then provide to users of this class, and then call the superclasses for implementing these methods. Unfortunately, you are introducing new classes just to make testing easier, keep in mind to use them and you may have to send them from UIGestureRecognizer to your own subclass depending on where you get the gesture recognizer link from.
Alternatively, your test can run new versions of target action methods in UIGestureRecognizer, which gives you the ability to track added targets. Just make sure you replace the original method implementations with your place when you are done, or future tests will have unexpected behavior.
Finally, you can find a private API call that gives you the ability to check registered target actions on a gesture recognizer. Just make sure that the private API call remains only in your test code.
source share