Reputation: 245
I think this is a really a question about the difference in the run time loop when running the app target vs running a unit test for for my view controller.
I know that reloadData is being called but the delegate methods are never called, even the method to ask in the first place how many rows there are is never called in unit test but it does when running as a application.
What am i missing in the wide world of iOS?
EDIT John was correct but for me the real issue was understanding that view controller's view is not instantiated until the views will actually be painted in the window. Since i was loading the view from a xib this requires that i actually call loadView (simple i know) from the unit test. Since objective c does not complain when you send a message to nil it never complained when i sent reloadData on a table that didn't exist
Upvotes: 0
Views: 246
Reputation: 20980
What I do is mock the table view controller, and ensure that reloadData
is called on it.
In separate tests, I confirm what happens when the delegate methods are called.
There's no need to test that Apple will call the delegate methods.
Upvotes: 2