View Source Criterion (Criterion v0.1.4)

A frame work to write unit tests as a list of steps. It can be used to write tests BDD style.

Usage

  1. Define scenarios using the scenario/2 macro.
  2. Inside each scenario, define steps using the step/2 macro.
  3. Steps can be either plain steps or steps with context variables.
  4. Shared steps can be defined external to the scenario

Example

# Define a scenario
step "Shared", context do
  context
end

scenario "Adding numbers" do
  # Use a shared step
  step "Shared"
  # Define a step
  step "Addition" do
    assert 1 + 1 == 2
  end



  # Define a step with context
  step "Addition with context", context do
    result = context[:a] + context[:b]
    assert result == 5
  end
end

Summary

Functions

Link to this macro

feature(description, list)

View Source (macro)
Link to this macro

scenario(description, test_vars \\ Macro.escape(%{}), list)

View Source (macro)
Link to this macro

step(description, step_var \\ Macro.escape(%{}), list)

View Source (macro)