Say I'm writing a unit test for a tableView:cellForRowAtIndexPath:
delegate method on a view controller. This method could return a couple of different configurations of cells depending on the index path I pass in.
I can easily assert on the cell.textLabel.text
property. But how can I assert that the cell.imageView.image
property contains the correct image? Neither the image or the imageView have (public API) properties I can use to find out the image name or file name.
The best I've come up with is creating the smallest possible valid .png (using [UIImage imageWithData:]
so I don't touch the disk in my unit tests) and asserting the byte array I get from cell.imageView.image
is the one I expect. I've created an OCHamcrest matcher to make this a little nicer but it's an unsatisfying and inflexible approach.
Has anyone got a better idea?