I’m trying to run my app in OCUnit environment. It uses a sqlite database and I’m having it in the app’s documents folder.
However when running from the tests, the path for the database is set to:
~/Library/Application Support/iPhone Simulator/6.0/Documents/Test.sqlite
While the same code gives me a path of
~/Library/Application Support/iPhone Simulator/6.0/Applications/34536EFB-005A-44A1-AD99-07D6B9F6888B/Documents/Test.sqlite
when I run it on the simulator.
How can I use NSDocumentDirectory in my tests and get what I need?
The application target is not the same as the test target, that’s why you get different paths.
When using OCUnit you can get the test
NSBundlelike this:You have to add the database to the resources of the test target and use it accordingly.
Or you can build the path like this (taken from this OS Answer):