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.

Comments

vernetto 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
Thanks for that.

Popular posts from this blog

Remove copy protection from PDF documents

The story of the Cobalt Qube

Jori Hulkkonen feat. Jerry Valuri - Lo-Fiction