Hooks¶
Hooks can be installed to run before
, around
and after
part of the test.
Hooks can be used to set up and flush test fixtures, apply mocks or capture failures.
-
class
aloe.
before
¶ -
@
all
¶ Run this function before everything.
Example:
from aloe import before @before.all def before_all(): print("Before all")
-
@
each_feature
¶ Run this function before each feature.
Parameters: feature (Feature) – the feature about to be run Example:
from aloe import before @before.each_feature def before_feature(feature): print("Before feature")
-
@
each_example
¶ Run this function before each scenario example.
Parameters: Example:
from aloe import before @before.each_example def before_example(scenario, outline, steps): print("Before example")
-
-
class
aloe.
after
¶ Run functions after an event. See
aloe.before
.Example:
from aloe import after @after.each_step def after_step(step): print("After step")
-
class
aloe.
around
¶ Define context managers that run around an event. See
aloe.before
.Example:
from contextlib import contextmanager from aloe import around @around.each_step @contextmanager def around_step(step): print("Before step") yield print("After step")
World¶
As a convenience, Aloe provides a world
object that can be used
to store information related to the test process. Typical usage includes
storing the expected results between steps, or objects or functions that are
useful for every step, such as an instance of a Selenium browser.
Aloe does not explicitly reset world
between scenarios or
features, so any clean-up must be done by the callbacks.
-
class
aloe.
world
¶ Store arbitrary data. Shared between hooks and steps.