I would like to write a unit test for something like the sockets example in the series 60 SDK documentation.

My problem is that I need to test an active object, specifically I am trying to test the CSocketsEngine of the sockets example.

After thinking about this for some time I realized the following approach should work.

1) A test method starts CTimeOutTimer registering the test class to be called when the timer goes off. (The test class must implement the TimerExpired() method.)

2) The test method then starts the active object under test. In this case it means calling the WriteL() method of CSocketsEngine.

3) The test method then busy waits watching some flag or uses some other method to block until either the timer has fired or the active object (CSocketsEngine) has completed its task and called the appropriate test class method with the results.

4) The test method (or another method responsible for the second half of the test, i.e. completeTestOne()) then informs the test framework how things went.

I am thinking that to do this must require having two threads. One running the test and the other running the active object under test. Unfortunately I can't find any good examples to help me along. Particularly sticky is the lack of a good threading example doing something similar. It doesn't help that I am far more familar with Java than C++.

Can anyone provide relevant guidance? How do others typically write unit tests for active objects? The approach I described is basically the same as what I remember doing in Java under similar circumstances.

James Carpenter