Unpredictable behavior around `during` and `atMost` of Awaitility
See original GitHub issueWhile I was testing Kafka I end up with some issues around Awaitility. The goal was to test that Kafka topic doesn’t contain the new records for a specified time. This is the simplified scratch of my test but it shows the problem. I expect that ConditionTimeoutException doesn’t throw in this case. But it does.
public static void main(String[] args) {
List<String> list = new ArrayList<>();
await("wait").during(5_000, TimeUnit.MILLISECONDS).atMost(5_000, TimeUnit.MILLISECONDS)
.pollInterval(100, TimeUnit.MILLISECONDS)
.until(() -> list, List::isEmpty);
}
I increased the atMost timeout to 5000 + pollInterval -> 5100 but still end up with an exception. On my local machine throwing exception was stoped closed the value of atMost timeout of 5170-5180. Should I keep something in mind? Or may the test isn’t correct?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Unpredictable behavior around `during` and `atMost` of ...
I increased the atMost timeout to 5000 + pollInterval -> 5100 but still end up with exception. On my local machine throwing exception...
Read more >Unpredictable behavior around `during` and `atMost` - Google Groups
While I was testing Kafka I end up with some issues around Awaitility. The goal was to test that Kafka topic doesn't contain...
Read more >Awaitility (Awaitility 4.1.1 API) - Javadoc.io
Awaitility is a small Java DSL for synchronizing (waiting for) asynchronous operations. ... Wait at most 5 seconds until customer status has been...
Read more >JUnit 5 User Guide
This behavior can lead to undesirable side effects if the code that is executed within the executable or supplier relies on java.lang.
Read more >"Thread.sleep" should not be used in tests - SonarSource Rules
Java static code analysis. Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your JAVA code.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you use
during
together withatMost
, theatMost
time must be greater (await needs some time to evaluate the condition). This code works@johanhaleby Yes