Below is my source code class where class constructor starting the thread.But in run() it is checking for not null value of a varible.So in order to test the using junit that variable should not be null.
public class MainClass extends Thread {
private SomeQue que;
private static final String THREAD_NAME = "s_thread";
private boolean isRunning = false;
public MainClass () {
setName(THREAD_NAME);
setIsRunning(true);
start();
}
public void run() {
while (isRunning()) {
if (que!= null) {
obj = que.pop();
if (obj != null) {
//....
}
}
}
}
}
If use
ReflectioinTerstUtils.setField(new MainClass(),"que",que);
we have to create the object to set data to variable to while creating object itself thread is getting started.So any ideas..