Search code examples
objective-cgh-unit

How to write GHunit test cases for delegate Methods?


Can we write GHunit test for delegate methods ? I have a delegate method and I am trying to write GHUnit Test for that delegate methods.


Solution

  • It depends on how you want to test the delegate method. If you want to test that a delegate method was called in a certain scenario, then you can use mock objects for that. OCMock is the typical framework on iOS and Mac OS for mocking. The last time I checked it played nicely with GHUnit. I'm using SenTest exclusively now, so I cannot say authoritatively.

    If you want to test the functionality of a delegate method, nothing prevents you from calling the delegate method directly from within the test case.