Is there a way to use Awaitility to assert that nothing has changed? I want to verify that a topic was not written to, but because there is no state change, Awaitility does not like this. E.g. this code gives the below error. Thanks
@Test
fun waitUntilListMightBePopulated() {
val myTopic: List<String> = emptyList()
await.atLeast(2, TimeUnit.SECONDS).pollDelay(Duration.ONE_SECOND).until {
myTopic.isEmpty()
}
}
ConditionTimeoutException: Condition was evaluated in 1005478005 NANOSECONDS which is earlier than expected minimum timeout 2 SECONDS
Awaitility throws ConditionTimeoutException when timeout is reached. One way to check that nothing changed in a predetermined time is to look for a change and assert that exception is thrown.
Please note, that this solution is very slow because of the minimal waiting time for a successful result and carries disadvantages related to throwing exceptions (What are the effects of exceptions on performance in Java?).