BDD
Global Callbacks
Global callbacks affect the execution of the entire test bundle CFC and all of its suites and specs.
beforeAll()
Executes once before all specs for the entire test bundle CFC. A great place to initialize the environment the bundle needs for testing.
afterAll()
Executes once after all specs for the entire test bundle CFC. A great place to teardown the environment the bundle needed for testing.
run( testResults, testBox )
Executes once so it can capture all your describe
and it
blocks so they can be executed by a TestBox runner.
Suite Callbacks
The following callbacks influence the execution of specification methods: it(), then()
. The great flexibility of the BDD approach is that it allows you to nest describe
, feature
, story
, given
, scenario
, when
suite blocks to create very human readable and organized documentation for your tests. Each suite block can have its own life-cycle methods as well. Not only that, if they are nested, TestBox will walk the tree and call each beforeEach()
and afterEach()
in the order you declare them.
TestBox will walk down the tree (from the outermost suite) for beforeEach()
operations and out of the tree (from the innermost suite) for afterEach()
operations.
beforeEach( body, data )
The body
closure will receive have the following signature:
afterEach( body, data )
The body
closure will receive have the following signature:
Here are some examples:
aroundEach( body, data )
The body
closure will receive have the following signature:
The spec
is the currently executing specification, the suite
is the suite this life-cycle is embedded in and data
is the data binding, if any.
Here is an example:
Life-Cycle Data Binding
You can pass in an argument called data
, which is a struct
of dynamic data, to all life-cycle methods. This is useful when creating dynamic suites and specifications. This data
will then be passed into the executing body for each life-cycle method for you.
Here is a typical example:
Last updated