I have a bit of trouble getting my test-suite up and running. Basically I added a new target to my application like so: Unit Testing Applications
As I want to test against my DA-classes and sqlite-database I use the following snipped to copy the database:
// First, test for existence.
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:DATABASE_Path];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:DATABASE_Path];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
but as it seems, NSBundle doesn't return the path to the database as expected.
Is there a simple fix to this? I wasn't able to fix it in the last couple of hours - so my next shot is you guys.
Any help or suggestion is highly appreciated!
Thanks a lot!
Tom