テストスイートを起動して実行するのに少し苦労しています。基本的に、次のように新しいターゲットをアプリケーションに追加しました: Unit Testing Applications
DA クラスと sqlite-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]);
}
しかし、NSBundle は期待どおりにデータベースへのパスを返さないようです。
これに対する簡単な修正はありますか?この数時間で修正できなかったので、次は皆さんです。
どんな助けや提案も大歓迎です!
どうもありがとう!
トム