View Source HypeLib.DocTester (HypeLib v2.2.0)

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, modules: [MyModule]
end

would result in the following MyTest module:

defmodule MyTest do
  use ExUnit.Case, async: true

  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.

expected-options

Expected options

NameExpected data typeDescription
moduleslist(module())A list of modules to generate the doctest directives for
asyncboolean()Gets passed down to the use ExUnit.Case call

changelog

Changelog

0-0-1

0.0.1

Initial implementation

2-0-0

2.0.0

Refactor to use a Keyword list as first argument instead of list of modules.

Added support for the modules and async option. Added documentation about the expected options.