quick_chex v0.2.1 QuickChex
main module with the main macros that you should use when writing tests.
Check the docs for the single methods for examples and use cases.
Summary
Macros
add use QuickChex
at the top of your ExUnit test module
check a property by giving the property name and a list of settings
specify a property with a single generate parameter
same as property/2 with two generated parameters
same as property/2 with three generated parameters
Macros
add use QuickChex
at the top of your ExUnit test module
Example
defmodule MyModuleTest do
use ExUnit.Case, async: true
use QuickChex # <- add this!
end
check a property by giving the property name and a list of settings
specify a property with a single generate parameter
A property has a name
to be identified by checks, a param1
that will
be generated, and a body to specify the requirements
Example
for a negate property of a Test.negate/1
function you could write a
property like this:
property :negate, value do
assert not value === Test.negate(value)
end
property :negate_two_time_means_doing_nothing, value do
res = value
|> Test.negate
|> Test.negate
assert value === res
end
same as property/2 with two generated parameters
Example
a property for the Test.add/2 function
property :add_is_commutative, n1, n2 do
assert Test.add(n1, n2) === Test.add(n2, n1)
end