Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

quality.testing

Avoid Thread.sleep in Java unit tests

Sleeping in tests slows CI and hides synchronization bugs.

#Metadata

Rule ID
java.testing.thread-sleep-in-unit-test
Severity
low
Confidence
0.6
Languages
java
Presets
recommended, strict
Stability
experimental
Applies to
block
Tags
java, rules-catalog, testing

#Why it matters

Prefer Awaitility, latches, or deterministic test doubles.

#Remediation

Use synchronization primitives, timeouts with polling, or move timing coverage to integration tests.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/java/java.testing.thread-sleep-in-unit-test.rule.yaml.