What are the best approaches to unit test methods that include I/O operations in iOS?
For example, I’m considering using Objective-C categories to redefine the behavior of I/O methods such as imageNamed. However, this prevents black-box unit testing because it’s necessary to know which I/O methods are used in the implementation.
Either pass in the results of the I/O operation so that test data can be supplied in place of the actual I/O data or use OCMock. I have used OCMock for exactly this purpose. If you are considering OCMock, do read at least the header file for all the methods available.
If working with Legacy code consider reading/studying the book Working Effectively with Legacy Code by Michael Feathers