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.
Questions:
- Is there a way to keep the object instantiated until such time as I see fit to destroy it - ie. after the tests have completed?
- If not, how could I create a class that blocks (ie. acts synchronously) until the tests are completed?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这个项目 https://github.com/hfossli/AGAsyncTestHelper 有一个非常方便的宏
,可以让你编写像这样的测试
This project https://github.com/hfossli/AGAsyncTestHelper has a very convenient macro
Which ables you to write the test like so
查看 SenTestingKitAsync 项目 - https://github.com/nxtbgthng/SenTestingKitAsync。相关博客在这里 - http://www.objc.io/issue-2 /async-testing.html
Checkout the SenTestingKitAsync project - https://github.com/nxtbgthng/SenTestingKitAsync. The related blog is here - http://www.objc.io/issue-2/async-testing.html
您可以使用信号量来等待异步方法完成。
http://samwize.com/2012/10/03/ Sentestingkit-不支持等待块/
You can use a semaphore to wait until the asynchronous method finishes.
}
http://samwize.com/2012/10/03/sentestingkit-does-not-support-wait-for-blocks/
两个选择:
Two options:
Kiwi 支持异步测试。 Kiwi 是一种 适用于 iOS 的行为驱动开发 (BDD) 库,扩展了SentTestingKit (OCUnit),因此很容易设置和使用使用。
另外,请查看:
Kiwi supports asynchronous testing. Kiwi is a Behavior Driven Development (BDD) library for iOS that extends SentTestingKit (OCUnit), so it's easy to set up & use.
Also, check out: