Thursday 15 July 2010

objective c - Kiwi - Expected subject to be nil, got KWAsyncVerifier -


I am using Kiwi to write a test for my app.

I wrote the test to test my API I was directed to the documentation for the asynchronous call test this example:

I have my test is long, so your problem a simplified version:

  description (@ "My class name" ^ {populate reference (@ "" ^ {this download ( "content", ^ {__blok Ansstiing * Test response Object = nil; __bloc nsERr * tester Roctor = nil; Maiklent * Apiaiclent = [Maiklent sharing client]; NSMutableURLRequest * request = [Apiklikent request with method: @ "Delete" path: @ "my / path" parameter: zero]; AFHTTPRequestOperation * Operation = [[Afactiteepiaraistopreshn Aeloosi] InitWithRequest: request] [Operation Set Endogenous Block Wishthrough: ^ (FHttpRequest Operation * Operation, ID ResponseObject) {testResponseObject = [[NSString alloc] initWithData: Response object encoding: NSUTF8StringEncoding];} Failure: ^ (F. Actiteepiarakestapreshn * operation, Ansiarar * error) {testError = error;}] [API client Ankyueactiteepiarakvestopreshna operation]; [[Expected testResponseObject) Later useEightIightAfter (100)] Equa L: @ "Expected Content"]; [[Required Future Value (Test errootter)] Finally, backingTimingout Fighter (100)] Binil []; }); }); });   

This is the thing that if everything works the desired work & amp; Operation failure block is never said to be successful & amp; Instead of zero for NSError I get the KWAsyncVerifier.

I am guessing because the Kiwi waits for the block where reference is used to execute testError which never happens & amp; So I have got KWAsyncVerifier trapped in zero instead of in testError.

Is there any alternative to check it out?

My first recommendation is that you should not test your libraries. In my example what I have read, you are basically checking that is working as a AFHTTPRequestOperation document, but it is not your responsibility to test. You should find out that you have called the air force in the right way, and it has given a feedback object or an error, your code behaves as you expect

Anyway, whatever you are watching, you have two one ???? In the same line: shouldEventually and shouldBeNil ; They use beNil , which is unavailable in 2.1, and I think they are bringing back you may find a discussion in

you can try the following to ensure that went Lee branch of failure:

  [operation set Smaplokblokvithःsfl: ^ (f Actiteepiarakvestopreshn * operation ID Pratikriyaobjekt) {testResponseObject = [[ NSString alloc] initWithData: feedback object encoding : Nsutfa8StringEncoding]; } Failure: ^ (f Actiteepiarakeistapeshn * operation, Ansiarar * Error) {// If we ever reach this branch it will fail [error Binil]; }]; [API Client NKHTTPRequest Operation: Operation]; [[Required FutureValue (testResponseObject) should be preceded by exposure on (100)] equals: @ "expected content"];   

shouldEvantuallyBeforeTimingOutAfter should keep the case of trial ?? Is alive ???? Waiting to check the response, but if you ever go through the failure branch, then other expectations will fail (and one of the responses will fail after 100 seconds). Hope it helps.

No comments:

Post a Comment