ctex v0.1.0 CommonTest.Wait

Macros for handling non-deterministic conditions in tests without waiting indefinitely.

Link to this section Summary

Functions

Repeatedly attempts the given block until the given time (in milliseconds) runs out or the do block returns true. In between each attempt, the current process will sleep for 10 milliseconds. If all attempts fail, the else block will be executed

Link to this section Functions

Link to this macro wait_until(time, list) (macro)

Repeatedly attempts the given block until the given time (in milliseconds) runs out or the do block returns true. In between each attempt, the current process will sleep for 10 milliseconds. If all attempts fail, the else block will be executed.

Example:

wait_until 10_000 do
  receive do
    :hello -> true
  after 0 ->
     false
  end
else
  :ct.fail(:was_not_greeted)
end