简体   繁体   English

如何使XCode 4的逻辑单元测试从笔尖正确初始化UIViewController?

[英]How do I make XCode 4's logic unit tests properly initialize a UIViewController from a nib?

In XCode 4.2, I have some logic tests that I want to exercise against a UIViewController that loads itself from a xib when initialized. 在XCode 4.2中,我有一些逻辑测试要针对初始化时从xib加载自身的UIViewController进行。 However, even though I've added all my xibs and images to the unit test bundle, whenever I try to run those tests i get the following error: 但是,即使我已将所有xib和图像都添加到了单元测试包中,但是每当我尝试运行这些测试时,我都会收到以下错误:

Could not load NIB in bundle: 'NSBundle
</Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/usr/bin>
(loaded)' with name 'MyController'

Is there something I can do to force my tests to find the xibs and other resources in the proper place? 有什么我可以强迫我的测试在适当的地方找到xib和其他资源的吗? Thanks. 谢谢。

Turns out i needed to change my unit tests to Application Tests from Logic Tests. 原来,我需要将单元测试从逻辑测试更改为应用程序测试。 This post has some useful info on that: 这篇文章有一些有用的信息:

Why does instantiating a UIFont in an iphone unit test cause a crash? 为什么在iPhone单元测试中实例化UIFont会导致崩溃?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM