DescribeFunction
Inspired by a conversation on Twitter, DescribeFunction adds an
additional layer of TDD to your Elixir application.
Usage
defmodule ExampleTest do
use ExUnit.Case, asnyc: true
import DescribeFunction
describe_function &Example.hello_world/0 do
test "hello_world functions as expected" do
assert Example.hello_world() == "hello world"
end
end
end
Assuming your Example module implements hello_world/0, your test will pass
or fail, based on its implementation. On the other hand, if Example.hello_world/0
is undefined, running your tests will raise
** (DescribeFunction.UndefinedFunctionError) function not defined: &Example.hello_world/0
The describe_function/2 macro validates that the function you are testing is
defined. This will catch untested changes to your application's API at a high
level in your test suite, resulting in a single, straightforward error, rather
than many errors that might occur at a more removed level of your API.
Installation
If available in Hex, the package can be installed
by adding describe_function to your list of dependencies in mix.exs:
def deps do
[
{:describe_function, "~> 0.1.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/describe_function.