From: Pit Capitain Date: 2007-01-05T04:39:00+09:00 Subject: Re: Problem in Unit Testing Methods that start new threads Hemant Kumar schrieb: > (...) > Earlier, I was writing Unit Tests for a networking application which i > wrote using EventMachine. Now since, EM is completely based on > callbacks, you can't do a check on return values of methods. Hence I had > to rely on doing asserts on instance variables. > > I would love to know, how do i go about unit testing in such cases. I > can't yet grasp concept of code that can be unit tested easily i guess. Hemant, in this case I'd try to use a framework like Mocha to create a mock for EventMachine. Then you can invoke the callbacks from the test code and verify that your application reacts as expected. I'm sure the results of invoking the callbacks can be examined from the outside, without having to look at instance variables. Regards, Pit