我的某些单元测试测试未在XCode 4.4中完成 [英] Some of my unit tests tests are not finishing in XCode 4.4

查看:56
本文介绍了我的某些单元测试测试未在XCode 4.4中完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到人们在这里和其他地方发布有关此问题的信息,但是我没有找到任何可行的解决方案.我正在使用XCode 4.4,并设置了一堆单元测试.我在此项目上之前都运行过它们,所以我知道它们应该在实际运行时通过/失败.

I have seen people posting about this here and elsewhere, but I haven't found any solution that works. I am using XCode 4.4 and have a bunch of unit tests set up. I have ran them all before on this project, so I know that they do pass/fail when they are supposed to if they are actually ran.

我大约有15个测试套件,每个套件包含1-7个测试.在大多数尝试中,除1(FooTests)外,所有测试套件都已完成(并通过).它给出警告:

I have about 15 test suites, and each one contains 1-7 tests. On most attempts, all of the test suites finished (and passed) except for 1 (FooTests). It gives the warning:

FooTests did not finish
    testFoo did not finish

无论未完成的测试发生了什么,XCode都会报告测试成功.还要注意的另一件事是,有时是另一项测试不会完成,而有时多个套件也不会完成.我没有注意到所有测试都能完成的情况,但是从这种看似随机的行为来看,我相信这是可能的.

XCode will report that testing was successful, regardless of what happens in unfinished tests. Another thing to note, sometimes it is a different test that will not finish, and sometimes multiple suites will not finish. I have not noticed a case where all tests do finish, but judging by this seemingly random behaviour I believe that it is possible.

那么,这是XCode中的错误吗?我想不出任何其他原因导致随机测试未完成,然后导致XCode报告一切成功.有什么解决办法吗?

So, is this a bug in XCode? I can't think of any other reason that tests randomly don't finish and then cause XCode to report that everything was successful. Are there any solutions?

推荐答案

我正在使用XCode 4.5.2.对于应用程序单元测试,如果您的测试套件完成得如此之快,以至于在此之前未正确加载主应用程序,您将收到警告.您可以通过在测试结束时添加一个睡眠来简单地避免此问题,如下所示.逻辑单元测试不会发生这种情况.

I am on XCode 4.5.2. For application unit test, if your test suites finish so quick that the main application is not correctly loaded before that, you will get the warning. You can simply avoid the problem by adding a sleep at the end of your test like following. It doesn't happen for logic unit test.

 [NSThread sleepForTimeInterval:1.0];

这篇关于我的某些单元测试测试未在XCode 4.4中完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆