资 源 简 介
This is a very simple and small (~250 LOC) library for writing concurrency tests with JUnit (tested with JUnit 4.10). There are 2 ways of using it:
ConcurrentTestRunner
If you want to run a test concurrently multiple times, just use the ConcurrentTestRunner. Optionally, the number of threads and a timeout can be specified either with @ConcurrentTest for all tests in a class or with @ConcurrentTestMethod for a specific test-method. By default, numThreads is set to 10 and timeout is set to 0, disabling the timeout.
```
@RunWith(ConcurrentTestRunner.class)
public class ConcurrentTestRunnerTest {
@Test
public void testRun10TimesByDefault() {
System.out.println("This is going to be printed 10 times.");
}
@Test
@ConcurrentTestMethod(numThreads = 20, timeout = 100)
public void testRun20TimesByDefault() {
System.out.println("This is going to be printed 20 times an