ex_test v0.0.2 ExTest
ExTest is a simple wrapper around ExUnit to support BDD (rspec) like syntax. It aims to be as lightweight as possible and keep the functionality of ExUnit. Any options passed to ExTest will be passed on to ExUnit.Case (e.g. async: true).
Using describe and it might aid your test organization and keep your tests more structured. The it macro is a wrapper for ExUnit.Case.test and works identically, however you may call multiple setups and nest these within describes.
Example
defmodule HelloWorldTest do
use ExTest #, async: true
describe "with some assigns" do
setup context do
{:ok, hello: :world}
end
describe "and some more assigns" do
setup context do
{:ok, Dict.put(context, foo: :bar)}
end
it "returns things from first context", context do
assert context[:hello] == :world
end
it "returns things from nested context", context do
assert context[:foo] == :bar
end
end
end
end
Summary
Functions
Adds module attributes to the ex_test context. As you cannot access module attributes after compilation, this alternative has been provided. Instead setting @module_attr "foo" you may specify it as put_module_attribute :module_attr, "foo". This is particular helpful when dealing with Phoenix Framework as it requires to set the Endpoint for controller tests
Macros
Creates a context for multiple setups and nesting its. Please see the module doc for an example
Creates a ExUnit.Case.test using a alternative syntax. This macro wraps the test macro and names the case it
Creates a ExUnit.Case.test using a alternative syntax but with a context
Functions
Adds module attributes to the ex_test context. As you cannot access module attributes after compilation, this alternative has been provided. Instead setting @module_attr "foo" you may specify it as put_module_attribute :module_attr, "foo". This is particular helpful when dealing with Phoenix Framework as it requires to set the Endpoint for controller tests.
Macros
Creates a context for multiple setups and nesting its. Please see the module doc for an example.
Creates a ExUnit.Case.test using a alternative syntax. This macro wraps the test macro and names the case it.
Example
it "adds two numbers", do: (assert 1 + 1 = 2)
Creates a ExUnit.Case.test using a alternative syntax but with a context.