File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Test case with multithreads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Test case with multithreads" Watch "Test case with multithreads" New topic

Test case with multithreads

Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Hi guys,
If a junit test case spawns new threads,
must all the threads terminate before the next test case is called?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I believe this depends on whether these threads are "daemon" or "regular" threads.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Andy Hunt
Ranch Hand

Joined: May 01, 2001
Posts: 54
My memory on this is a little fuzzy, but as I recall JUnit as shipped has (or had) some bugs with regard to handling multiple threads.
There was a patch available from a 3rd party (just a Google away :-) that dealt with threads in a much more robust manner. In the patched version, I believe the answer to your question is "yes."

/\ndy Hunt<br /> <a href="" target="_blank" rel="nofollow"></a>
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Thank you Lasse and Andy.
subject: Test case with multithreads
Similar Threads
threads and genrics
How many Threads ?
JUnit and multithread
How many....
Test your business service