简体   繁体   中英

IPhone unit testing, how to support asynchronous function invoking based on event bus pattern?

In my project the event communication uses event bus pattern, who will be response to manage all the request and response, it has been packaged into a library and upper layer app will invoke this library to communicate with outside.

Now in my unit testing I need to test whether these API work well or not for some cases, dues to the response is asynchronous, seems we need a method to handle it in unit testing. Hey guys, do you have any experience on how to implement such kind of issue? Any idea and discussion will be appreciated, thanks in advance.

BTW: 1. We use the following model to send request and deal with response in block.

sendRequestWithTicket:ticket 
    successBlock: ^ (response*) {}
    failBlock: ^ (response*) {}
  1. We use OCUnit as unit testing framework.

对于单元测试来说似乎很难做到,对于系统集成测试来说可能是可行的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM