I have created two classes which extends Thread and implements the run method.
class A extends Thread implements MyInterface { public void run() { } public function() { B b= new b(); b.start(); } } class B extends Thread implements OtherInterafce { MyClassC object = new MyClassC(); public void run() { for(;;) { object.callMethod(); object.callMethod2(); //Perform some operations } } } Now I want to write unit Test for these classes, Since Class B is creating a daemon thread there is no exit condition, I am not sure how to test this part. I can create a mock of object but how many times that will run I am not sure, so how should I very the calls to the methods.
Threadinstance, and itsrun()method will be run in a thread if some other thread callsnew B().start().