Tuesday, March 27, 2007

Creating multithreaded tests for JUnit

Sometimes (I hope) you discover code you've written that was not as thread safe as you thought it was. Testing this can be quite a painful experience. I just found this article on Java World describing ways to create JUnit tests in a multithreaded environment. Looking at the date it was published, the article is quite old, so I was wondering if maybe there are better techniques than those described in the article.

3 comments:

Pierre said...

same problem here, it's surprising that there is so little support for multithreaded JUnit tests...

I would suggest either using JUnitPerf http://clarkware.com/software/JUnitPerf.html

or switching to TestNG which is waaaay better than JUnit (even of JUnit4). TestNG supports natively this feature with the -parallel option.

Anonymous said...

There is an easier way to do it using what's described here

kennywest said...

Thanks for that.