← 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 75
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. **Separate the logic from the concurrency.** Inject the executor. Test the logic with a same-thread executor, deterministically; test the concurrency separately and explicitly. 2. **Write the failure-path tests first**, because they are the ones that will otherwise not exist: cancel mid-flight, interrupt, time out, reject at the limit, fail the dependency. 3. **Replace every sleep with a synchronisation point** — a latch, a barrier, `Awaitility` with a bound. A sleep is either a flaky test or a slow one, and usually both. 4. **Assert invariants, not schedules.** After owned work terminates, a