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").
I suggest reading about JUnit @Rule
to use them for concurrency tests.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With