← ClaudeAtlas

concurrency-testinglisted

Testing concurrent Java so failures appear in CI rather than in an incident: what a passing concurrency test does and does not prove, replacing sleeps with latches and deterministic executors, explicitly exercising cancellation, interruption and timeout, stress tests that assert invariants, and soak tests that catch permit and connection leaks. Use when a test uses Thread.sleep to wait for another thread, when a concurrency test is flaky and a retry is proposed, when cancellation or timeout paths have no test at all, when tests assert on thread names or pool sizes and broke after a virtual-thread change, when a race was found in production and nobody can reproduce it, or when a concurrency limit or fallback has never been exercised under failure. Does not cover proving memory-model claims (java-memory-model, varhandles-and-memory-ordering), benchmark methodology (jmh-microbenchmarks), load generation and rates (load-testing), or diagnosing a live system (concurrency-diagnostics).
robsonkades/agent-skills · ★ 2 · Testing & QA · score 68
Install: claude install-skill robsonkades/agent-skills
# Concurrency Testing ## Purpose Get concurrency defects to fail a build. Most never do, because the tests that would catch them are the ones nobody writes: cancellation, interruption, timeout, rejection, and the behaviour of a limit at its boundary. What does get written — a test that starts two threads and asserts the happy path — is the one that proves the least. The second purpose is calibration. A green concurrency test is weak evidence, and treating it as strong evidence is how a race gets shipped with confidence. ## Workflow The ordinary examples use Java 21+ final APIs and JUnit Jupiter; the structured-scope example uses Java 25 preview. Inspect compiler release/toolchains, CI JDK, resolved test libraries and timeout mode before adapting them. Keep the project's baseline and existing test framework; do not upgrade Java or enable preview merely to use this skill. 1. **Identify the contract and reuse its existing tests.** Separate pure logic where useful: a same-thread executor can test it, while controlled queued execution or real workers test asynchronous boundaries. Do not change the executor model when that changes the contract. 2. **Select missing failure-path tests** for the actual lifecycle: cancel mid-flight, interrupt, time out, reject at the limit, fail the dependency. Establish the expected caller outcome, physical work lifetime and resource owner before writing the oracle. 3. **Replace sleeps used for coordination with an observable checkpo