iPhone 单元测试挂起; 无法调用-applicationDidFinishLaunching:
我为使用 Google 构建的 iPhone 项目设置了单元测试Toolkit for Mac 框架位于 OCUnit 之上。 我有一个名为“单元测试”的依赖项目,它根据需要构建并运行测试。
但后来一切都停止了,原因我无法理解。 突然,我的“单元测试”可执行文件启动并坐在那里,永远等待。 它永远不会到达应用程序委托的 -applicationDidFinishLaunching:
方法,该方法调用实际的单元测试。 将 NSLog 插入委托的 -init
方法中告诉我该方法被调用,但应用程序永远不会“完成”启动。
如果我修改运行“单元测试”可执行文件的 shell 脚本并取出 -RegisterForSystemEvents
参数,则可执行文件立即存在(它不运行测试)并给出以下消息:
由于没有系统事件服务器而终止。
(如果您想在没有 SpringBoard 的情况下运行,请运行 EventPump 或传递参数“-RegisterForSystemEvents”。
由于当我删除该参数时它终止,我很好奇该参数到底是做什么的以及如何做的,因为它似乎会导致挂起但由于没有它就无法运行任何测试,因此我需要确定如何使其再次运行。但是,Google 没有提供与当前情况相关的任何内容的链接,并且开发文档中没有任何
想法。
I have unit tests set up for my iPhone project built using the Google Toolkit for Mac framework on top of OCUnit. I have a dependent project called "Unit Tests" that builds and runs the tests as needed.
But then it all stopped working, for no reason that I can fathom. Suddenly, my "Unit Tests" executable launches and just sits there, waiting, forever. It never gets as far as the Application Delegate's -applicationDidFinishLaunching:
method, which is what calls the actual unit tests. Inserting an NSLog into the delegate's -init
method tells me that that method gets called, but the application never "finishes" launching.
If I modify the shell script that runs the "Unit Tests" executable and take out the -RegisterForSystemEvents
argument, the executable exists immediately (it runs no tests) and gives me the following message:
Terminating since there is no system event server.
(Run the EventPump or pass the argument "-RegisterForSystemEvents" if you want to run without SpringBoard.
Since it terminates when I remove that argument, I'm curious what exactly that argument does and how, since it would seem to be causing the hang. But since no tests run without it, I need to determine how I can get it working again. However, Google doesn't provide links to anything relevant to the current situation, and nothing in the dev docs is helpful.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果 Xcode 在构建过程中挂起(构建结果窗口显示“正在运行自定义 shell 脚本”,但在那里停止),请选择单元测试目标并单击“获取信息”。 然后选择“属性”选项卡并清除“主笔尖文件”文本字段并清理目标。
单击“构建并开始”现在应该可以成功运行测试。
If Xcode hangs during the build (the build results window shows 'Running custom shell script' but stalls there), select the unit test target and click 'Get Info'. Then select the Properties tab and clear the text field for 'Main Nib File' and clean the target.
Clicking 'Build and Go' should now successfully run the tests.
我们从今天早上就解决了这个问题。 树顶 GTM 不应再悬挂。 它与委托在有机会获得 applicationDidFinishLaunching 事件之前被切换有关。 此帖子中有更多详细信息:
http://groups. google.com/group/google-toolbox-for-mac/browse_thread/thread/513a3252d655e1e3
We fixed this issue as of this morning. Top of tree GTM should not hang anymore. It has to do with the delegate being switched before it had a chance to get the applicationDidFinishLaunching event. More details in this thread:
http://groups.google.com/group/google-toolbox-for-mac/browse_thread/thread/513a3252d655e1e3
万一其他人遇到这个问题,这就是我最终完成的工作。
我制作了代码的本地副本,然后将整个代码库恢复到 Git 存储库中之前的提交。 干净的结帐仍然可以很好地运行测试。 然后,我逐个文件重新引入我的更改,检查每次增量合并后单元测试是否有效。
当单元测试表明失败时,我预计会达到某个点,但它从未出现。 我合并了所有更改,单元测试仍然运行良好。
显然,这对于没有 SCM 系统且无法恢复工作副本的人来说没有任何帮助。 在这种情况下,创建一个干净的项目并将代码拉过来将是最好的选择。
In case someone else comes across this, here's what I finally got working.
I made a local copy of the code, then reverted the entire codebase back to a previous commit in my Git repository. That clean checkout could still run tests just fine. I then reintroduced my changes in file by file, checking that unit tests worked after each incremental merge.
I expected to hit some point when the unit tests stated failing, but it never came. I merged all the changes in and the unit tests were still running fine.
Obviously, this isn't going to be of help to anyone who doesn't have a SCM system with a working copy to revert to. In that case, making a clean project and pulling your code over would be the best option.
我也遇到了同样的问题 - 看起来我弄乱了 IB 中的 AppDelegate。
确保:
您有 AppDelegate 类
在 NIB 中实例化。
其
window
出口指向该 NIB 中的 UIWindow。
任何其他渠道都指向哪里
他们应该(就我而言,
tabBarController 到我的实例
UITabBarController)。
最后是你的文件的所有者
将插座点委托给您的
AppDelegate
哇。
I had this same problem - looks like I had messed up my AppDelegate in IB.
Make sure:
You have your AppDelegate class
instanced in the NIB.
That its
window
outlet points atthe UIWindow in that NIB.
That any other outlets point where
they should (in my case,
tabBarController to my instanced
UITabBarController).
And finally that your File's Owner
delegate outlet points to your
AppDelegate
Whew.