View Source Criterion (Criterion v0.1.8)
A frame work to write unit tests as a list of steps. It can be used to write tests BDD style.
Usage
- Define scenarios using the
scenario/2
macro. - Inside each scenario, define steps using the
step/2
macro. - Steps can be either plain steps or steps with context variables.
- 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