As a rule, you do not use unit test concurrency of multi-threaded applications, since unit tests are not reliable and reproducible - due to the nature of concurrency errors, it is usually impossible to write unit tests that are sequentially either fail or successful, and therefore unit tests of parallel code are usually don't do very useful unit tests.
Instead, you unit test each individual component of your application as usual and rely on load testing sessions to identify concurrency issues.
However, there are some experimental load testing platforms for testing parallel applications, such as Microsoft CHESS - CHESS repeatedly runs a given unit test and systematically examines every possible parallel test rotation. This makes your unit tests reliable and repeatable.
At the moment, CHESS is still experimental (and probably not applicable to the JVM) - now stick with load testing to screen out concurrency problems.
Justin
source share