Load a test image for unit testing

Viewed 7560

I'm writing a test for a class that loads an image and does some color manipulation. The image is loaded with

    UIImage* image = [UIImage imageNamed:imageName];

If I run the app everything is fine and the images are loaded as expected. I added a unit test that shall use a specific test image to be loaded during the test. If I run the test fixture the image is not loaded. What I read so far is that the method imageNamed always loads from the app bundle's resource folder. How can I change this to the bundle of my test?

6 Answers

To change app bundle:

let bundle = Bundle(identifier: "org.cocoapods.ACSPLib")

let photo = UIImage(named: nameofThePhoto, in: bundle, compatibleWith: nil)

the bundle identifier

bundle identifier for pod

Related