How to write multi-threaded unit tests?

Viewed 4977

I'd like to know if there are some unit testing frameworks which are capable of writing multi-threaded tests easily?

I would imagine something like: invoke a special test method by n threads at the same time for m times. After all test threads finished, an assertion method where some constraints should be validated would be invoked.

My current approach is to create Thread objects inside a junit test method, loop manually the real test cases inside each run() method, wait for all threads and then validate the assertions. But using this, I have a large boilerplate code block for each test.

What are your experiences?

3 Answers
Related