YvanMazy / concurrent-testing

Minimal Java library to create concurrency tests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🧵 concurrent-testing

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: Release

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>

About

Minimal Java library to create concurrency tests.


Languages

Language:Java 100.0%