Xcode 4中的SenTestingKit:异步测试? [英] SenTestingKit in Xcode 4: Asynchronous testing?

查看:45
本文介绍了Xcode 4中的SenTestingKit:异步测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种使用SenTestingKit在客户端代码和服务器之间进行集成测试的方法.我没有运气.看起来,一旦代码在某个方法中运行,该对象就会被破坏.这意味着任何异步响应都不会调用选择器.

I have been searching for a way to use SenTestingKit to do some integration testing between my client-side code and our server. I haven't had any luck. It seems that once the code is run in a method, the object gets destroyed. This means that any asynchronous responses never call the selectors.

问题:

  1. 有没有一种方法可以保持对象实例化,直到我认为合适的时候可以销毁它-即.测试完成后?
  2. 如果没有,我如何创建一个阻止(即同步执行)直到测试完成的类?

仅供参考,我正在运行一台测试服务器,我知道预期的结果.

FYI, I'm running a test server where I know the expected results.

我已经做了很多谷歌搜索,但是还没有看到关于此的一种或另一种证明.我相信其他人也会对此感兴趣.

I've done a fair bit of Googling but haven't seen proof one way or another about this. I'm sure others would be interested as well.

推荐答案

两个选项:

  • 切换到 GHUnit ,它实际上包含对等待异步事件的支持
  • 缩小测试的设计范围,以便您可以按现状测试事物.例如.测试您的控制器代码是否会导致选择器分离并运行,并(单独)测试该选择器是否应执行其应做的工作.如果这两种方法都起作用,那么您可以确信控制器可以分离出正确的工作.
  • switch to GHUnit, which actually contains support for waiting for asynchronous events
  • narrow the design of your tests so that you can test things as they stand. E.g. test that your controller code causes a selector to be detached and run, and (separately) test that this selector does what it ought. If both of those things work, then you can be confident that your controller detaches the correct work.

这篇关于Xcode 4中的SenTestingKit:异步测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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