Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Junit multiple threads

I have a test case that provides arguments and executes the main method of a class. What would be the best approach using Junit to have multiple threads concurrenlty execute the main method of class.

like image 573
Forum Member Avatar asked Dec 16 '22 08:12

Forum Member


1 Answers

Not sure if TestNG is an option for you, but it's pretty straightforward with it:

@Test(invocationCount = 100, threadPoolSize = 10)
public void myTest() { ... }

This will cause the test method to be invoked 100 times from 10 different threads. If this test passes and you run it a lot, you can be fairly confident that the code under test is multithread safe.

like image 137
Cedric Beust Avatar answered Dec 26 '22 14:12

Cedric Beust