本文介绍了使用OCunit在iOS上测试异步代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有没有人知道任何允许使用OCUnit测试异步代码的现有库? 我正在考虑像 GHAsyncTestCase 这样的东西,但它从 SenTestCase 开始。Does anyone know of any existing library that allows testing asynchronous code with OCUnit?I'm thinking about something like GHAsyncTestCase but that delivers from SenTestCase.我问,因为如果我找不到任何我要将 GHAsyncTestCase 移植到OCUnit,但我不想已经由其他人完成的重复工作。I'm asking because if I don't find any I'm going to port GHAsyncTestCase to OCUnit but I don't want to duplicate work done already by someone else.推荐答案 Piotr:您可能对我使用 Mimic 所做的工作感兴趣,这是一个用Ruby编写的网络存根工具,它允许您在高级,可以使用提供的包装器从Objective-C中使用。You might be interested in the work I've done with Mimic, a network stubbing tool written in Ruby which lets you stub requests at a high-level and can be used from your Objective-C using the supplied wrapper.关于异步测试,请看一下我写的一个小实用工具 AssertEventually 。With regards to asynchronous testing, please take a look at a little utility I wrote called AssertEventually. 这个例子显示Mimic和assertEventually正在运行。This example shows both Mimic and assertEventually in action.此外,你可能想看看 Kiwi - 这是一个基于OCUnit构建的优秀的Objective-C测试框架。我最近提供了一个补丁,用于将我的AssertEventually行为移植到Kiwi,它允许你编写如下内容:In addition, you might want to look at Kiwi - it's a great little Objective-C testing framework that is built on top of OCUnit. I recently contributed a patch to port my AssertEventually behaviour over to Kiwi which lets you write things like:id someObject = nil;[do SomethingThatFetchesSomeObjectAsynchronously];[[theObject(&someObject) shouldEventually] equal:@"some result"]; 这篇关于使用OCunit在iOS上测试异步代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 09:00