From: Allison N. <dem...@ma...> - 2008-06-12 11:39:26
|
Hi everyone, I'm trying to write a unit test at the moment that uses rspec, and I'm having some problems. In my app I have an NSTimer that fires every second after I call a start method on my controller. The callback function of the timer updates some values on the screen. It works like a charm in the real app. In my unitary tests, I try to call the same 'start' method, and then sleep the test thread for x seconds, at the end of which I try to verify that a counter has been incremented in my controller 5 times. The problem is that the timer callback is never called, so the counter is never updated. I'm guessing that this has something to do with run loops in Cocoa, and specifically that I never actually set up a Cocoa runtime in my rspec test. Can anyone confirm this? Does anyone have a nice elegant way of doing this sort of test? If not, I guess I can always manually call the timer callback manually in the test, to simulate a timer. Trouble is, that means that I'm not actually testing the timer functionality itself, which is nevertheless an important part of my app. Any ideas? Alli |