使用 google toolbox for mac 进行单元测试编译时出错
您好,我的应用程序运行良好,但是当我尝试运行单元测试时,我收到此错误...
2010-10-19 00:27:49.919 AssignmentUnitTest[27988:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'*** -[NSURL initFileURLWithPath:]: nil string parameter'
具有讽刺意味的是,我已经搜索了整个项目&我没有任何类似的使用 **[NSURL initFileURLWithPath:]**
的代码行,
我几乎在上面浪费了半天时间,但没有取得任何成功。
我在项目中使用 coredata &下面是带有堆栈跟踪的屏幕截图。
谁能引导我走向正确的方向。
谢谢
**编辑:** 此问题的解决方案是不仅添加 .xcdatamodel 文件,还添加根文件.xcdatamodeld。 Core Data 无法找到我的模型,因此显示此错误。希望有一天它能帮助别人。
Hi my application runs fine but when I try to run the unit tests I am getting this error...
2010-10-19 00:27:49.919 AssignmentUnitTest[27988:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'*** -[NSURL initFileURLWithPath:]: nil string parameter'
Irony is I have searched the whole project & I dont have any similar line of code that uses **[NSURL initFileURLWithPath:]**
I have pretty much wasted half of my day on it without any success.
I am using coredata in the project & below is the screen shot with stack trace.
Can anyone please guide me to the right direction.
Thanks
**EDIt : ** The solution to this problem is to add not only the .xcdatamodel file but the root file .xcdatamodeld. Core Data was having trouble finding my model so was displaying this error. Hope it helps somebody someday.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阅读屏幕截图中的调用堆栈。它表示您的
managementObjectModel
方法发送了[NSURL fileURLWithPath:]
,并且 调用了initFileURLWithPath:
。因此,找到您发送[NSURL fileURLWithPath:]
的点,并将您的参数修正为该消息。您传递的参数无效表明您为路径传递了
nil
(也许您尝试在包中查找该文件,但它不存在或具有与您查找的名称不同的名称),或者您传递了一个指向不是字符串的对象的指针(也许您有一个字符串但保留不足,并且在其位置创建了另一个对象)。Read the call stack in your screenshot. It says your
managedObjectModel
method sent[NSURL fileURLWithPath:]
, and that calledinitFileURLWithPath:
. So, find the point where you sent[NSURL fileURLWithPath:]
and fix your argument to that message.The argument you passed being invalid suggests that either you passed
nil
for the path (perhaps you tried to find the file in your bundle but it isn't there or has a different name than you looked for), or you passed a pointer to an object that isn't a string (perhaps you had a string but under-retained it and a different object was created in its place).SDK 的某些版本中存在一个错误,该错误破坏了模拟器中的异常处理。
您可以在设备上运行测试吗?
There is a bug in some version(s) of the SDK that broke exception handling in the simulator.
Can you run the tests on a device?