With Fennec you can define setup, teardown, and case methods that apply
to tests in unique ways. These methods can be used to set variables,
attributes, environment, or anything else.
A case is a scenario under which your tests should pass. When you
define multiple case blocks and multiple tests, all your tests will be
run for all your cases.
before_each and after_each define code that should be run before or
after each test block. Each test will only run once, but the
before_each will run multiple times, once per test. after_each is the
same but runs after each test.
before_all and after_all define blocks that only ever run once.
before_each runs once before all tests, and after_each runs once, after
all tests.
around_each and around_all are more complicated, but they are useful
when paired with 'local'.
Grouping
Grouping is done using the 'describe' keyword. Any setup, teardown, and
case methods defined within a describe block will ONLY apply to test
blocks defined within that describe block. You can nest describe
blocks, child describe blocks will inherit the setup, teardown and case
methods from the parent describe blocks.
No case or before_each applies to OUTSIDE
TESTS_A and TESTS_B get everything except SETUP_B
TESTS_INNER gets every setup and teardown.
Post-Testing
Sometimes you want to have tests that run after all the test blocks and
workflows complete. That is you want them to be the absolute last thing
run. In these cases you can pass a coderef to done_testing(). This will
ensure the codeblock is the very last thing run before Fennec cleans
itself up. This is important because You cannot have tests after
done_testing!
This is rarely useful, however it can be necessary when testing Fennec
plugins to ensure you ran the desired number of tests, something Fennec
normally prevents you from worrying about.