I use GHUnit for unit testing, and wrote subclasses of GHAsyncTestCase, but in my case, the web service is not like an active service request where you send request and expect to receive an answer, instead of this, my web service is a passive type service where you subscribe to a channel then it can send you message, but there is no guarantee about how frequent the server pushes messages to subscribers, in this case, say 50 secs after subscribing, server pushes a message and another message after 30 secs, then should I do:
[self waitForStatus:kGHUnitWaitStatusSuccess timeout:50.0f];
to verify the first message, or is there any smart way for doing this?
Thanks!
It depends on what you want to do.
If you want to verify the data coming from your server, you can send a request to the server to ask it push something immediately and use
to wait for the pushed messages.
It you want to verify your objective-c code, you can send some fake data to your object.
If you are using NSURLConnection to get your data, call the delegate method below with some fake data in your testing code
The idea behind unit testing is “unit” testing. The testing code should focus on the “unit” you want to test. It is a good practice to exclude other uncontrollable factors (like network availability) from your testing.