Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frameworks for Unittests for Multithreading in Java [closed]

Which frameworks would you recommend for writing unit tests for multithreading code in Java? Like, for example, when you have a program that is supposed to execute a bunch of threads with several allowed paths of executions and certain excluded paths (like "executable unit 1, 2 and 3 can run in parallel, at least two should be run in parallel, and 4 always has to run after 3").

like image 287
Tim van Beek Avatar asked Apr 13 '12 13:04

Tim van Beek


3 Answers

I suggest reading about JUnit @Rule to use them for concurrency tests.

like image 74
nobeh Avatar answered Oct 20 '22 21:10

nobeh


I recommend ContiPerf2 since it is a very easy to use framework. Although I do not think it will provide the possibility to declare execution pathes or something like that.

like image 22
Omnaest Avatar answered Oct 20 '22 19:10

Omnaest


You can use parametrized JUnit tests, as described here: http://junit.org/junit/javadoc/4.5/org/junit/runners/Parameterized.html

But you will need to program thread logic yourself, for example by using different thread pools.

You can take a look at pathfinder (http://javapathfinder.sourceforge.net/) if you want to prove that your code is thread safe.

like image 32
hgrey Avatar answered Oct 20 '22 21:10

hgrey