hub4j / github-api

Java API for GitHub
https://github-api.kohsuke.org/
MIT License
1.12k stars 718 forks source link

Ban use of `Thread.sleep()` in tests unless specifically approved #1815

Open bitwiseman opened 4 months ago

bitwiseman commented 4 months ago

We add await-based pauses the don't slow down CI testing:

https://github.com/hub4j/github-api/blob/main/src/test/java/org/kohsuke/github/GHWorkflowRunTest.java#L574-L584

There are some timing based tests, but they are the exception. Most tests don't need to care.
We need to make await() an easily used test helper, enforce not calling Thread.sleep() unless specifically approved, and provide a helpful failure message regarding using await.

Perhaps also a sleepWhenTakingSnapshot() method. See #1810 for example of why.