DescribeFunction (describe_function v0.1.0)
Inspired by a conversation on Twitter, DescribeFunction
adds
an additional layer of TDD to your Elixir application.
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.
## 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
Link to this section Summary
Functions
This macro expands on the functionality of ExUnit.Case.describe/2
by
validating that the function passed as its first argument exists.
Link to this section Functions
This macro expands on the functionality of ExUnit.Case.describe/2
by
validating that the function passed as its first argument exists.
This will catch untested changes to your application's API at a higher level in your test suite, resulting in a single, straightforward error, rather than many errors that might occur at a more removed level in your API.
usage
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