• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Testing async code with OCUnit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Testing async code with OCUnit (From: Nir Soffer <email@hidden>)

  • Prev by Date: Re: How to revert xcode version?
  • Next by Date: Re: Visual Studio-style indent
  • Previous by thread: Testing async code with OCUnit
  • Next by thread: gcc 3.3 and 10.3 features
  • Index(es):
    • Date
    • Thread