View Source HypeLib.DocTester (HypeLib v0.0.1)

A utility module for efficiently generating doctest directives

examples

Examples

The following example

defmodule MyModule do
  @doc """
  A function that calculates the summary of two numbers

  ## Examples

  iex> MyModule.add(1, 2)
  3
  """
  def add(a, b), do: a + b
end

defmodule MyTest do
  use HypeLib.DocTester, [MyModule]
end

would result in the following MyTest module:

defmodule MyTest do
  use ExUnit.Case

  doctest MyModule
end

which then can be run by ExUnit.

In this example ExUnit would run the add/2 test where the expected result is 3.