Fixtures
Fixtures allow you to run code before and after tests, to set up the context in which tests should be run.
A fixture is just a function that calls another function passed as an argument. It looks like this:
There are two way of registering fixture in clojure: :each
and :once
.
We use use-fixtures
to register fixtures.
One time fixture
The fixture registered with :once
will be called before any tests
are run and it will be pased a function to call that will invoke all
the tests. You can have a fixture that only runs once, around all
the tests in the namespace.
Each fixture
The fixture registered with :each
will be called before each tests
are run and it will be passed a function to call that will invoke every
test. Fixtures are run repeatedly, once for each test, they can be
attached to the current namespace like this,
Real World Example
Source: spymemcat