Very small Java library for doing concurrency tests during unit testing. It's a tool that I use for personal projects, it is not intended to be really maintained.
Here is a small example of use:
@RepeatedTest(10) // To reduce randomness, use repeated test
void testAtomicCounter() {
final Counter counter = new AtomicCounter();
ConcurrentTester.start(() -> {
// Code executed in different threads
counter.increment();
}, THREADS, ITERATIONS);
assertEquals(THREADS * ITERATIONS, counter.get());
}
To use the project as a dependency, you can add it using Maven
or Gradle.
Last version:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.YvanMazy:concurrent-testing:VERSION'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.YvanMazy</groupId>
<artifactId>concurrent-testing</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>