GHUnit 用于集成测试 iOS 网络功能
我有一个具有异步网络访问功能的 iOS 应用程序(但这同样适用于 OS X 应用程序)。使用 GHUnit 并且无需手动执行内部运行循环或同步异步操作,是否可以让测试方法运行异步操作并在异步操作完成后验证结果。
我在 GHUnit 中没有看到任何允许这样做的内容,但我可能是盲目的。我确实知道有人使用内部运行循环来执行此操作,但我有很多集成测试,并且不想为每个测试都进行设置。
I have an iOS application (but this is just as applicable to an OS X app) that has async network access functions. Using GHUnit and without manually doing inner run loops, or synchronization of async operations, is it possible have a test method run an async operation and verify the results AFTER the async operation is complete.
I don't see anything in GHUnit to allow this but I might be blind. I do know of people who do this with inner run loops, but I have a bunch of integration tests and don't want to set this up for each test.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到了同样的问题(以及博客文章,其中包含由于比较运算符而过滤的一些关键部分)。
您正在 GHUnit 中寻找
GHAsyncTestCase
。描述中的示例比我能做的更好。I just stumbled into the same problem (and blog post, which contains some key pieces filtered due to comparison operators).
You're looking for
GHAsyncTestCase
within GHUnit. The example in the description does a better job than I'd be able to do.GHUnit 异步示例向您展示了如何设置,但在异步操作完成后不运行任何测试。
做到这一点的技巧是在
waitForStatus
之后调用断言。这里的一个例子: http://samwize.com/2012/ 11/25/创建-async-test-with-ghunit/
The GHUnit async example shows you how to setup, but does not run any tests after the async operation is completed.
The trick to do it is to call the asserts AFTER
waitForStatus
.An example here: http://samwize.com/2012/11/25/create-async-test-with-ghunit/