These days m testing a huge multithreaded application with JUnit. Faced lot of issues during the tests, but could not find aapropriate answers for them yet. Forced to change the base code to be tested, which I know will not be acceptable by our client, its not practical also. Why one will change its code to be a non multithreaded if he requires it in its app.
First and the biggest problem came accross when there were Thread.sleep() calls and the app. is supposed to be running forever. To put an example here, the application is developed to run endlessly checking for some data in the DB, if it finds any, it proccesses it and sleep for some interval, and the process goes like that forever. So does the JUnit test, it will not come out again.
Second issue was more surprising. When there is a new thread started, JUnit care least to wait for it to complete its work, it will just come out as it doesnt know its running for a multithreaded app. Seems it doesnt understand threading.
There are few issues other than MT like having System.exit(n) in your code. When your testcases hits a function having System.exit(n), the behavior of JUnit suddenly gets changed. You wont get proper report from JUnit. And one just keeps on thinking what went wrong.
Would appreciate inputs on the issues.