View Source SmartCity.TestHelper (smart_city_test v3.0.0)

Common utilities for use in test cases

Link to this section Summary

Functions

Helper function for asynchronous testing

Link to this section Types

@type asserting_function() :: (() -> no_return() | boolean())

Link to this section Functions

Link to this function

eventually(function, dwell \\ 2000, max_tries \\ 5)

View Source
@spec eventually(asserting_function(), integer(), integer()) :: :ok | none()

Helper function for asynchronous testing

  • Repeats the given block (zero-arity function) until a timeout occurs or it returns a truthy value.
  • Catches ExUnit assertions and continues to try the block
  • Re-runs block one last time if it times out so assertions are run and throw helpful diffs, etc.