Re: Testing async code with OCUnit
Re: Testing async code with OCUnit
- Subject: Re: Testing async code with OCUnit
- From: Chris Hanson <email@hidden>
- Date: Thu, 24 Aug 2006 21:30:15 -0700
On Aug 24, 2006, at 5:07 AM, Nir Soffer wrote:
- (void) doSomethingWithCondition:condition
{
if (condition)
[self preformSelector:@selector(taskDidFinishWithObject:)
withObject:bar afterDelay:0.0];
}
However, when this call happen, this test was finished long time
ago. I want to the test code to wait for some reasonable time and
report a failure if foo did not get the message.
It seems to be impossible with OCUnit.
You'll have to spin the run loop yourself to test something like
this. Methods like -[NSObject
performSelector:withObject:afterDelay:] typically register with the
run loop and are intended for use from a context where a run loop is
running (e.g. an application or a daemon).
OCUnit doesn't run tests in a run loop, and even if it did, this
would still be hard to test without running your own run loop. And
you'd run into the same behavior if you tried to use -
doSomethingWithCondition: in a command-line tool that isn't running a
run loop.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden