unit测试时,coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.
2012-04-09 18:00
369 查看
遇到一个很奇怪的现象。unit测试时,coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.
但实际跑程序时。增删保存都没问题。
我花了很多的时间在问题抛出的地方在[contextsave:&error];
后来发现,早在初期化_persistentStoreCoordinator 时就报错了
if (![_persistentStoreCoordinator
addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeUrl
options:nil
error:&error]) {
// Handle the error.
}
&error 显示的信息为The model used to open the store is incompatible with the one used to create
上网搜了下,大意是说可能在改变entities的atrributes时损坏了存储文件。直接把存储文件删除即可。
我试了下,果然就ok了。
另外两个人和我的现象是一样的,不过在storeUrl指定的地方根本没有文件夹,别说文件了。按照storeUrl
的路径把文件夹建好,也就ok了。
我还有个疑问,为什么实际跑画面的时候是好的。只有单体测试的时候有问题?
我又在跑画面的时候,跟进去看了下。实际跑画面的storeUrl的根路径与单体时不同,有一串看似是UUID的随机数。
估计是跑画面的时候有建新目录的权限。
而跑单体的时候既没有建目录权限,也没有删文件权限。所以当存储改变时会报错。
但实际跑程序时。增删保存都没问题。
我花了很多的时间在问题抛出的地方在[contextsave:&error];
后来发现,早在初期化_persistentStoreCoordinator 时就报错了
if (![_persistentStoreCoordinator
addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeUrl
options:nil
error:&error]) {
// Handle the error.
}
&error 显示的信息为The model used to open the store is incompatible with the one used to create
上网搜了下,大意是说可能在改变entities的atrributes时损坏了存储文件。直接把存储文件删除即可。
我试了下,果然就ok了。
另外两个人和我的现象是一样的,不过在storeUrl指定的地方根本没有文件夹,别说文件了。按照storeUrl
的路径把文件夹建好,也就ok了。
我还有个疑问,为什么实际跑画面的时候是好的。只有单体测试的时候有问题?
我又在跑画面的时候,跟进去看了下。实际跑画面的storeUrl的根路径与单体时不同,有一串看似是UUID的随机数。
估计是跑画面的时候有建新目录的权限。
而跑单体的时候既没有建目录权限,也没有删文件权限。所以当存储改变时会报错。
相关文章推荐
- Core Data存储数据出错(This NSPersistentStoreCoordinator has no persistent stores (unknown))
- coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.
- "NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent sto
- 核心数据库CoreData之NSPersistentStoreCoordinator持久化存储
- 002_你实现过多线程的Core Data么?NSPersistentStoreCoordinator,NSManagedObjectContext和NSManagedObject中的哪些需要在线程中
- Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has mult
- Springboot启动后报错【This application has no explicit mapping for /error, so you are seeing this as a fallback····】
- Oracle AWR 报告中 No data exists for this section of the report 说明
- Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source
- on the web appear:"No data returned for this view.This might be because the applied filter excludes
- web页面中通过js方法回调部分native的功能出现错误 Object [object Object] has no method 'openI***e' at null:1
- There is no WRITEABLE property named 'unitcoefficient' in class 'com.rhyton.pems.core.domain.EnergyM
- Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has mult
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 错误解决办法
- [pcl::PCDWriter::writeASCII] Input point cloud has no data
- 'IContextMenu' : no GUID has been associated with this object问题的解决
- 错误:redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled
- Cannot create an NSPersistentStoreCoordinator with a nil model 问题解决
- 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration a