Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to test AFNetworking
    primarykey
    data
    text
    <p>*<strong>Edit - I originally wanted to test <code>AFNetworking</code> using <code>Nocilla</code> but ended up using <code>OHHTTPStubs</code> to do the job. I've answered the original question below, using <code>OHHTTPStubs</code> *</strong></p> <p>Original Question:</p> <p>I want to test the APIClient of our app - the bare bones of one of methods which needs to be tested is detailed below. So I need to mimic the <code>HTTPRequestOperationWithRequest:</code> call from <code>AFNetworking</code>. <code>Nocilla</code> seems like an option to do this (more suitable than <code>OCMock</code>). I've checked out <a href="https://github.com/luisobo/Nocilla/blob/master/NocillaTests/Hooks/NSURLRequest/AFNetworkingStubbingSpec.m" rel="nofollow">the github page</a> which deals with <code>Nocilla</code> and <code>AFNetworking</code> but I'm not sure how to apply it to my problem - the syntax isn't very familiar. </p> <ul> <li>So my wondering if someone could give me a hint as to how I might use <code>Nocilla</code> in this case?</li> <li>Also, must one use <code>Kiwi</code> with <code>Nocilla</code>? </li> </ul> <p>Thanks in advance :)</p> <pre><code> -(AFHTTPRequestOperation *)getBroadcastsForChannel:(TINChannel *)channel startTime:(NSDate *)date limit:(NSNumber *)limit pastLimit:(NSNumber *)pastLimit fields:(NSArray *)fieldsArray interval:(TINBroadcastsInterval)interval completionBlock:(void (^)(NSArray *broadcasts, NSError *error))block { // Some setup here NSURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:params]; AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { NSError *error; NSDictionary *responseDic = [self parseResponse:responseObject error:&amp;error]; if (error) { if (block) { block([NSArray array], error); } return; } // Parse the response object here if (block) { block([NSArray arrayWithArray:broadcastsOutput], nil); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { if (block) { block([NSArray array], error); } }]; [self enqueueHTTPRequestOperation:operation]; return operation; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload