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

__using__()

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(name, check_name \\ nil, settings)

check a property by giving the property name and a list of settings

property(name, param1, list)

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
property(name, param1, param2, list)

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
property(name, param1, param2, param3, list)

same as property/2 with three generated parameters