assert_eventually

Latest version: 1.0.0 registry icon
Maintenance score
0
Safety score
0
Popularity score
70
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
1.0.0 0 0 0 0 0
0.3.1 0 0 0 0 0
0.3.0 0 0 0 0 0
0.2.2 0 0 0 0 0
0.2.1 0 0 0 0 0
0.2.0 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

1.0.0 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Apache-2.0   -   Apache License 2.0

Not a wildcard

Not proprietary

OSI Compliant



AssertEventually

CircleCI

Very simple test helper for Elixir's ExUnit framework that allows to use standard ExUnit assertions along with expressions that may fail several times until they eventually succeed.

Documentation

Documentation can be found on https://hexdocs.pm/ex_assert_eventually.

Installation

The package can be installed by adding assert_eventually to your list of dependencies in mix.exs:

def deps do
  [
    {:assert_eventually, "~> 1.0.0", only: :test}
  ]
end

AssertEventually is usually added only to the :test environment since it's used in tests. To also import AssertEventually's formatter configuration, add the :dev environment as well as :test for assert_eventually and add :assert_eventually to your .formatter.exs:

[
  import_deps: [:assert_eventually]
]

Just tell me how to use it already...

Here you go (just replace ComplexSystem with something of yours):

defmodule MyApp.SomeTest do
  use ExUnit.Case, async: true

  # Fail after 50ms of retrying with 5ms time between attempts
  use AssertEventually, timeout: 50, interval: 5

  test "get meaningful value by using normal assert" do
    {:ok, server_pid} = start_supervised(ComplexSystem)

    eventually assert {:ok, value} = ComplexSystem.get_value(server_pid)
    assert value == 42
  end

  test "get meaningful value by using assert_in_delta" do
    {:ok, server_pid} = start_supervised(ComplexSystem)

    eventually assert_in_delta 42, elem(ComplexSystem.get_value(server_pid), 1), 0
  end
end

For more details please consult the documentation.